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
https://forums.phpfreaks.com/topic/169184-helpa-simple-question/
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, 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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.