<?php
// Define a sample object
$obj = new stdClass();
$obj->name = "John Doe";
$obj->age = 30;
$obj->city = "New York";
// Access values from the object
echo "Name: " . $obj->name . "<br>";
echo "Age: " . $obj->age . "<br>";
echo "City: " . $obj->city . "<br>";
?>
Name: John Doe
Age: 30
City: New York
stdClass()
` class in PHP. We then assign some values to the object properties using the `->
` operator. Finally, we access the values of the object properties using the same operator and print them on the screen using the `echo
` statement.