Home  >  Article  >  Backend Development  >  php stdClass种

php stdClass种

WBOY
WBOYOriginal
2016-06-13 10:56:17781browse

php stdClass类

1.数组转对象。

$arr_a=array();
$arr_a['a']=1;
$arr_a['b']=2;

可以写成
$arr_a=array();
$arr_a=(object)$arr_a;
$arr_a->a=1;
$arr_a->b=2;

2.stdClass的使用

$obj_a=new stdClass();
$obj_a->a=1;
$obj_a->b=2;

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn