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

PHP standard class (stdclass) usage example

高洛峰
Release: 2016-12-21 14:14:13
Original
1423 people have browsed it

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);
Copy after login

The running results are as follows:

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

When using type conversion, the standard class is used

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

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!


Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template