PHP使用对象作为var [duplicate]

This question already has an answer here:

Dear all PHP developer.

I am thinking of implementing different approach on my PHP Framework. I tried to search for solution but I could not get what i am after. I have a class Property. It has many protected properties one of them is $value. My requirements are, 1. I need to initialise Object->$value as variable, 2. I need to access Object->$value as variable. I have the following code for your reference:

Property.php

class Property{
    /**
    * @var string $name
    * @var string $element
    * @var string $value

    */
    protected $name;
    protected $value;
    protected $element;



    public function __construct($name, $element){
        $this->setName($name);
        $this->setElement($element);
    }
    public function setName($name){
        $this->name=$name;
    }
    public function getName():string {
        return $this->name;
    }
    public function setElement($element){
        $this->element=$element;
    }
    public function getElement():string{
        return $this->element;
    }
    public function setValue($value){
        $this->element->setText($value);
    }
    public function getValue():string {
        return $this->element->getText();
    }
}

Implementation.php

$try= new Property("test","try");

// now here what i need to have
$try="i am testing";   // should equal or call to:  $try->setValue("i am testing");

$tmpAnother= $try;     // should equal/call to:  $tmpAnother= $try->getValue();

I am not sure if it is good approach or I am in good direction. Need your comment on this approach or solution if it is possible.

Thank you all...

</div>

It won't work, and the reason is that PHP doesn't support operator overloading.

See: Does php support operator overloading?