â ī¸ Warning â ī¸ Deprecated Code! This video tutorial contains outdated code.
đĄ If you wish to update it, any AI assistant will update the code for you in seconds.
đĄ If you wish to update it, any AI assistant will update the code for you in seconds.
Using the get_object_vars Function
The get_object_vars() function will return an associative array containing the available properties of an object instance.
demo.php
<?php
include_once("class1.php");
$myObj = new class1();
$arr = get_object_vars($myObj);
foreach($arr as $name => $val){
echo "<h3>$name | $val</h3>";
}
?>
class1.php
<?php
class class1 {
public $city = "Las Vegas";
public $state = "Nevada";
public $country = "USA";
}
?>