Question : how to create object in php wihtout class
Answered by : gursewak-singh
//You can use stdClass which is sort of empty template
$object = new stdClass();
//Assign property
$object->property = 'Here we go';
//Now if we dump it var_dump($object); /* outputs: object(stdClass)#2 (1) { ["property"]=> string(10) "Here we go" } */
//Even shorter
$object = (object) ['property' => 'Here we go'];
Source : https://stackoverflow.com/questions/14395631/php-create-object-without-class | Last Update : Sat, 02 May 20