Home > Article > Backend Development > Parsing PHP data type objects (Object)
ObjectInitialization
To create a new object object, use The new statement instantiates a class:
<?php class foo { function do_foo() { echo "Doing foo."; } } $bar = new foo; $bar->do_foo(); ?>
If you convert an object to an object, it will not change in any way. If a value of any other type is converted to an object, an instance of the built-in class stdClass will be created. If the value is NULL, the new instance is empty. ArrayConvert to object
使键名成为属性名并具有相对应的值。对于任何其它的值,名为 scalar 的成员变量将包含该值。 <?php $obj = (object) 'ciao'; echo $obj->scalar; // outputs 'ciao' ?>
The above is the detailed content of Parsing PHP data type objects (Object). For more information, please follow other related articles on the PHP Chinese website!