PHP转换成对像

Converting to object

If an object is converted to an object, it is not modified. If a value of any other type is converted to an object, a new instance of the stdClass built-in class is created. If the value was NULL, the new instance will be empty. Arrays convert to an object with properties named by keys, and corresponding values. For any other value, a member variable named scalar will contain the value.

<?php
$obj = (object) 'ciao';
echo $obj->scalar;  // outputs 'ciao'
?>

参考:

1.http://www.php18.com/forum/scalar-topic-18517-1-1.html

2.http://blog.sina.com.cn/s/blog_4918b42901008o42.html

原文地址:https://www.cnblogs.com/Athrun/p/php_scalar.html