Recorrer propiedades objetos

 <?php

        //Recorrer objetos

        class MiClase {

            public $var1 = 'valor 1';
            public $var2 = 'valor 2';
            public $var3 = 'valor 3';
            protected $protected = 'variable protegida';
            private $private = 'variable privada';

            function iterateVisible() {
                echo "MiClase::iterateVisible:<br/>";
                foreach ($this as $clave => $valor) {
                     echo $clave." - ".$valor."<br/>";
                }
            }

        }
        $clase=new MiClase();
        foreach($clase as $clave=>$valor){
            echo $clave." - ".$valor."<br/>";
        }
        $clase->iterateVisible();
        
        ?>