3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Vehiculo{ private $puerta; private $ruedas; public function __construct($puerta = 2, $ruedas = 2){ $this->puerta = $puerta; $this->ruedas = $ruedas; } public function __get($atributo){ return $this->$atributo; } public function __set($atributo, $valor){ if(property_exists($this, $atributo)) { $this->$atributo = $valor; } } } $coche = new Vehiculo; echo $coche->puerta=5; if(property_exists($coche, "ruedas")) { echo "\nexiste la propiedad puerta\n"; }
based on UPSft
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.1.0 - 7.3.0alpha1
5 existe la propiedad puerta