runeveryday Posted August 7, 2009 Share Posted August 7, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/169184-helpa-simple-question/ Share on other sites More sharing options...
scvinodkumar Posted August 7, 2009 Share Posted August 7, 2009 Check this http://in.php.net/manual/en/function.mysql-fetch-object.php Quote Link to comment https://forums.phpfreaks.com/topic/169184-helpa-simple-question/#findComment-892678 Share on other sites More sharing options...
The Little Guy Posted August 7, 2009 Share Posted August 7, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/169184-helpa-simple-question/#findComment-892679 Share on other sites More sharing options...
runeveryday Posted August 7, 2009 Author Share Posted August 7, 2009 property? thank you very mucn for you reply! Quote Link to comment https://forums.phpfreaks.com/topic/169184-helpa-simple-question/#findComment-892687 Share on other sites More sharing options...
runeveryday Posted August 7, 2009 Author Share Posted August 7, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/169184-helpa-simple-question/#findComment-892705 Share on other sites More sharing options...
The Little Guy Posted August 7, 2009 Share Posted August 7, 2009 if it was a function (method), it would look like this: format_date($comment->timestamp()); Quote Link to comment https://forums.phpfreaks.com/topic/169184-helpa-simple-question/#findComment-892708 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.