When I read a piece of code today, I found that stdclass is used in it. It can be seen from the context that this is not a custom class and should be built in PHP.
Therefore, it can be used directly:
$ OBJ = new stdclass; <br/> $ obj-> name = 'linvo '; <br/> $ obj-> age = 22; <br/> var_dump ($ OBJ );
In addition to a predefined class introduced after 5.0, the Manual does not seem to have introduced much.
I searched the internet to find out:
Stdclass is a base class of PHP. Almost all classes inherit this class, so it can be new at any time and make this variable an object. At the same time, this base class has another special point, that is, there is no method.
What is the purpose of such a thing? In general, it allows programmers to simply save a series of variables.
Why not use arrays? In a weak language such as PHP, arrays are more convenient, but sometimes arrays have the disadvantage of performing operations such as $ array1 = $ array2, PHP generates a copy of $ array2 to $ array1. In Versions later than 5.0, the assignment of an object is not like this, but directly transfers the reference (similar to $ obj1 = & $ obj2; In PhP4 ;).
Currently, I only know so much about it :)