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. Quote Link to comment 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>'; } } ?> Quote Link to comment 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! Quote Link to comment 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.