Guest clv Posted June 14, 2010 Report Share Posted June 14, 2010 This is no doubt one of those questions that is so basic, no one bothers to explain it in the books. When reading something like $object->property or $stefan->name; do we read the arrow operator like a possessive apostrophe? i.e. Stefan's name (the name of Stefan)? Quote Link to comment Share on other sites More sharing options...
falkencreative Posted June 14, 2010 Report Share Posted June 14, 2010 When reading something like $object->property or $stefan->name; do we read the arrow operator like a possessive apostrophe? i.e. Stefan's name (the name of Stefan)? I'm not sure there are any specific rules on this, but I suppose you could do that, since you are talking about a variable or function that is associated with a particular object. Quote Link to comment Share on other sites More sharing options...
krillz Posted June 15, 2010 Report Share Posted June 15, 2010 It's like in Java Integer.parseNext(); but in PHP we use the arrow so we would do Integer->parseNext(); So what you do is specify the object type, in this case Integer and call the function in that object by the refference -> to call the object member parseNext(). So to formally wrap it up: It's how PHP let's you reference a member of some class. If there was some class reference stored in the variable $foo and there was a member function 'noWay()' you could call it by writing '$foo->noWay()', it's the namespace separator or object access operator. you use it to reference member data of an object. 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.
Note: Your post will require moderator approval before it will be visible.