PHP中的“ - >”做什么? [重复]

This question already has an answer here:

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.

</div>

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

<?php

$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.

-> Is Used to refer the Classes And Objects for more information check here.

-> Sign used in objects, to access it's property and methods.

class example{
    public $prop1 = 'Hello World';

    public function sayHello(){
        echo $this->prop1;
    }
}

$example = new example();
$example->sayHello();

Ref: Classes and Objects in PHP

You haven't posted any code, so I'm not 100% sure where you saw this, but I'm almost certain you are referring to something like this:

$foo = new Foo();
echo $foo->bar;

In this example, -> is used to access a property of an object, $foo. It can also be used to access a method, as in $foo->baz();.