damianjames Posted July 25, 2008 Share Posted July 25, 2008 This is an embarrassing question, but I can't seem to search for it and find anything. (when I search for "PHP ->" Google ignores the ->, and PHP.net wants me to give at least 3 characters in a search). So obviously I'm new at PHP, and I'd like either a quick explanation of when and why to use -> with a variable instead of =, or at least a primer I can read. I appreciate your responses, sorry if this is a bit too newbie. Link to comment https://forums.phpfreaks.com/topic/116648-solved-gt-versus/ Share on other sites More sharing options...
discomatt Posted July 25, 2008 Share Posted July 25, 2008 -> is a reference to a method or vairable within an object, and = defines a variable. <?php $foo = 'bar'; $object = new someClass; $object->methodInSomeClass( $foo ); $foo = $object->varInSomeClass; echo $foo; class someClass { public $varInSomeClass = 'Hello World'; public function methodInSomeClass( $param ) { echo $param . '<br>'; } } ?> Link to comment https://forums.phpfreaks.com/topic/116648-solved-gt-versus/#findComment-599771 Share on other sites More sharing options...
damianjames Posted July 25, 2008 Author Share Posted July 25, 2008 Thank you kindly for your response and explanation - I appreciate it! Link to comment https://forums.phpfreaks.com/topic/116648-solved-gt-versus/#findComment-599776 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.