If all Classes should exist in a default level, then the top level should be the most general Class, which is to say extremely abstract , each lower-level Class is more specialized than the upper-level Class (that is, the parent class). Based on this idea, in PHP, this top-level Class is named "stdClass", and as a "Standard Class", you can think of it as a class without any attributes and methods.
The purpose of using stdClass: Add properties to the base object (Base Object) at runtime
Question
You want to create an object and add some properties to it, but you don't want to formally define it as an explicit class. This is quite useful in some cases, for example when you define a method to return an object with certain attributes (undefined), such as when returning a result set object through mysql_fetch_object(), for certain attributes When you are not sure whether it exists and don’t want to check isset one by one.
Solution
Use PHP built-in class, stdClass, for example:
<?php $sql="SELECT name,email FROM users WHERE id=$id"; $dbh=mysql_query($sql); $obj=mysql_fetch_object($dbh); if(!$obj) $obj=new StdClass; $array=array( 'name'=>$obj->name, 'email'=>$obj->email );
Finally, this usage of setting properties for an empty object at runtime is not difficult to see and will also bring us some problems, such as you cannot really determine who this object is and what its purpose is.