What is stdClass class?
stdClass is Generic empty class in PHP.
OR
stdClass is universal base class in PHP.
Question: Why stdClass class is used?
stdClass is used to create anonymous objects with properties.
Question: Where it is used?
When we need to create an object without having new class. then we used stdClass class which is inbuilt in PHP.
After create object, we can add properties.
Question: How to create stdClass class?
Question: Can we set different variables in StdClass?
Yes, We can do both get and set.
See Example Below:
stdClass is Generic empty class in PHP.
OR
stdClass is universal base class in PHP.
Question: Why stdClass class is used?
stdClass is used to create anonymous objects with properties.
Question: Where it is used?
When we need to create an object without having new class. then we used stdClass class which is inbuilt in PHP.
After create object, we can add properties.
Question: How to create stdClass class?
$object=new stdClass();
Question: Can we set different variables in StdClass?
Yes, We can do both get and set.
See Example Below:
//First, create an object with use of stdClass $object=new stdClass(); //Set new variables in $object $object->name='Web Technology Experts Notes'; $object->url='web-technology-experts-notes.in'; //Get the variables values echo $object->name; echo $object->url;