天天看點

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​​

申明

非源創博文中的内容均收集自網上,若有侵權之處,請及時聯絡,我會在第一時間内删除.再次說聲抱歉!!!

博文歡迎轉載,但請給出原文連接配接。