âš ī¸ 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.

Using the get_class_vars Function

Published : November 22, 2014   •   Last Edited : November 24, 2025   •   Author : Adam Khoury
The get_class_vars() function will return an associative array containing all properties of a class that are available in the current scope. demo.php
<?php
include_once("class1.php");

$properties = get_class_vars("class1");
foreach($properties as $k => $v){
    echo "<h3>$k = $v</h3>";
}
?>
class1.php
<?php
class class1 {

    public $color1 = "blue";
    private $color2 = "white";
    public $color3 = "silver";

}
?>