Help with syntax
Moderator: General Moderators
Help with syntax
I am just learning php 5 and mysql and am running across statements with "->" in them. What does it mean and when do you use it? Sorry for my ignorance, but I have googled it and there is NOTHING. Thanks!
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Help with syntax
-> provides access to a property or method of an instantiated object. So:
I recommend you read this page in the manual (and then the whole Classes and Objects section):
http://www.php.net/manual/en/language.oop5.basic.php
Code: Select all
class Foo {
public $bar = 5;
public function baz() {
return "Hello";
}
}
$foo = new Foo();
echo $foo->bar; // outputs '5'
echo $foo->baz(); // outputs 'Hello'http://www.php.net/manual/en/language.oop5.basic.php
(#10850)