Jump to content

[HELP]a simple question


runeveryday

Recommended Posts

i am a newbie of php,maybe this is a simple and a little silly question,but i want to know the true principle of it.hope someone can help me .

Q:

there is a function,and have a form like this $a->b in a function bracket.what is $a->b mean and have what effect? the sign '->' mean is?

 

eg:

format_date($comment->timestamp)

anyone's reply is appreciated!

Link to comment
Share on other sites

Basically you are working with classes, and in your example, $comment is an instance of some class (probably something to do with comments). since "timestamp" doesn't have any parenthesis after it, it is not a function, (its called a "method", when your dealing classes). So that means that timestamp is a variable in the comment class.

 

Most languages use a '.' instead of a '->' to tell the parser what class/method/variable to use.

 

Note: in a class its not called a variable, its called something else but I cant remember right now sorry.

 

More info: oop

Link to comment
Share on other sites

Basically you are working with classes, and in your example, $comment is an instance of some class (probably something to do with comments). since "timestamp" doesn't have any parenthesis after it, it is not a function, (its called a "method", when your dealing classes). So that means that timestamp is a variable in the comment class.

 

Most languages use a '.' instead of a '->' to tell the parser what class/method/variable to use.

 

Note: in a class its not called a variable, its called something else but I cant remember right now sorry.

 

More info: oop

 

Basically you are working with classes.

how do you know that is classes not  function.

thx!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.