How can you access and display the individual fields of a stdClass object in PHP?

To access and display the individual fields of a stdClass object in PHP, you can simply use the arrow (->) operator followed by the field name. This allows you to access the properties of the object as if they were public variables. You can then echo or print these fields to display their values.

// Create a new stdClass object
$obj = new stdClass();
$obj->name = "John";
$obj->age = 30;

// Access and display individual fields
echo "Name: " . $obj->name . "<br>";
echo "Age: " . $obj->age;