I know how to access an object's property if the property type is a simple string
class My_Class {
public $var = 'Hello';
// More stuff...
}
$obj = new My_Class();
echo $obj->var
But imagine if My_Class::var
was type object
which itself had properties. How would I access one of those properties?
只需像下面这样继续沿着链条工作:
$obj->var->property_name;
The same way you'd access a regular object but working through the instance of the container class. For example:
$obj->var->some_method() or $obj->var->some_public_property;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.