Asked 3 years ago
20 Jul 2021
Views 443
Alexis

Alexis posted

What is stdClass in PHP?

What is stdClass in PHP?
lain

lain
answered Jul 20 '21 00:00

stdClass is like constructor for creating new empty dynamic class


$new= new stdClass;

above code will creae new standard class by new stdClass .


print_r($new);

it will print stdClass Object()


one can add properties as much as they want dynamically

$new= new stdClass;
$new->status=1;
print_r($new);

it will print stdClass Object( [status] => 1 )

Post Answer