3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class person { var $name; // variable inside class = property function __construct($persons_name=null) { $this->name = $persons_name; } function set_name($new_name) { $this->name = $new_name; } function get_name() { // function inside class = method return $this->name; } } // Create object WITHOUT constructor by calling a method $SecurityEngineer = new person(); $SecurityEngineer->set_name("Debbie B"); echo "<br>Debbie's full name: " . $SecurityEngineer->get_name()."<br>"; // Create object WITH a constructor $WanEngineer = new person("Lisa L"); echo "Lisa's full name: " . $WanEngineer->get_name();
Output for 5.1.3 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
<br>Debbie's full name: Debbie B<br>Lisa's full name: Lisa L
Output for 5.0.0 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/15uV1 on line 3 <br>Debbie's full name: Debbie B<br>Lisa's full name: Lisa L
Output for 4.3.0 - 4.4.9
<br>Debbie's full name: Debbie B<br>Lisa's full name: