Home >php教程 >PHP开发 >PHP standard class (stdclass) usage example

PHP standard class (stdclass) usage example

高洛峰
高洛峰Original
2016-12-21 14:14:131425browse

The examples in this article describe the usage of PHP standard classes (stdclass). Share it with everyone for your reference, the details are as follows:

php has a built-in standard class (stdclass)

<?php
$obj = new stdclass();
echo &#39;<pre class="brush:php;toolbar:false">&#39;;
var_dump($obj);
$obj->a = 1;
$obj->b = 1;
var_dump($obj);

The running results are as follows:

object(stdClass)[1]
object(stdClass)[1]
 public &#39;a&#39; => int 1
 public &#39;b&#39; => int 1

When using type conversion, the standard class is used

$arr = array(&#39;a&#39;=>1);
var_dump((object)$arr);

I hope this article will be helpful to everyone in PHP programming.

For more articles related to PHP standard class (stdclass) usage examples, please pay attention to the PHP Chinese website!


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