Monday, July 29, 2019

What does "->" do in PHP?




I am studying how to connect database while learning PHP. Just a quick question. Does anyone can tell me what does "->" sign do in PHP? I cannot understand the functionality of this sign so that I have no idea how to edit the code. Thank whoever answer this.


Answer



For real quick and dirty one-liner anonymous objects, just cast an associative array:




$obj = (object) array('foo' => 'bar', 'property' => 'value');


echo $obj->foo; // prints 'bar'
echo $obj->property; // prints 'value'

?>


... no need to create a new class or function to accomplish it.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...