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

 

 

相关文章:

  • 2022-12-23
  • 2022-02-05
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
  • 2021-05-10
猜你喜欢
  • 2021-10-20
  • 2022-02-26
  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
  • 2021-06-30
相关资源
相似解决方案