I know that this is a simple question. However, due to the nature of the question, I can't find any information by searching for it. What does the below mean in PHP? -> Code (markup): Is it similar to this? .= Code (markup): If so, what are the differences? Or, can someone send me a link to where I can learn more about it? Thanks
-> is associated with PHP Classes .= means append this to the variable Now you have the basic meaning, I'm sure you can look it up Jay
Thanks. I now know that -> is associated with PHP classes. However, PHP classes is quite a large subject, and there is a lot of information about PHP classes. I have searched many PHP websites for '->'. Unfortunately, none of them pull up anything. Probably because most search engines don't consider -> a valid search. I know this is something so simple that most people don't even mention what it does because it is common knowledge. Does anyone have a more in depth explaination.
It's called arrow operator, and it's used when working with Objects (not only classes). Its purpose is basically to access methods/variables within the scope of a class, or to access values of an object. Further references: www.php.net/object www.php.net/mysql_fetch_object www.php.net/get_browser www.php.net/language.oop5.basic
Here's a brief explanation: "You use the "->" operator to refer to a variable or a function of an instance." Taken from : http://www.phpbuilder.com/columns/rod19990601.php3?page=2 This one looks a little better as it explains each part as it goes along: http://articles.techrepublic.com.com/5100-22-1045062.html
Examples: class MyClass { public $var; function isTrue() { return $this->var; } } //Instantiate a new object $object=new MyClass(param); //Set the MyClass member 'var' to true $object->var=true; //Call method isTrue, which returns the value of member 'var' if($object->isTrue()) { echo "Class member var is true."; } //Outputs "Class member var is true." PHP: