3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Programmer { // Class Properties var $name; // Programmer's name var $experience; // How long has been programming var $lang; // Favorite Language var $education; // Highest degree earned // Class Constructor - function same name as the class function Programmer($name, $experience, $lang, $education) { $this->name=$name; $this->experience=$experience; $this->lang=$lang; $this->education=$education; } // Getter/Setter functions for all properties in the class function get_name() { return $this->name; } function set_name($newname) { $this->name = $newname; } function get_experience() { return $this->experience; } function set_experience($newexperience) { $this->experience = $newexperience; } function get_lang() { return $this->lang; } function set_lang($newlang) { $this->lang = $newlang; } function get_education() { return $this->education; } function set_education($neweducation) { $this->education = $neweducation; } // Utility data dump function function output() { echo "Programmer Name: ".$this->name."<br>"; echo $this->name." has ".$this->experience." years of programming experience.<br>"; echo $this->lang." is ".$this->name."'s favorite programming language.<br>"; echo $this->name." holds the degree: ".$this->education."<br><br>"; } } // Instantiating a programmer $paul = new Programmer('Paul Conrad',12,'C++','Bachelor of Science in Computer Science'); $paul->output(); // Oops, Paul has programmed alot longer than 12 year, really is 22 years $paul->set_experience(22); $paul->output(); ?>
Output for 7.0.0 - 7.1.0
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Programmer has a deprecated constructor in /in/BKBOm on line 2 Programmer Name: Paul Conrad<br>Paul Conrad has 12 years of programming experience.<br>C++ is Paul Conrad's favorite programming language.<br>Paul Conrad holds the degree: Bachelor of Science in Computer Science<br><br>Programmer Name: Paul Conrad<br>Paul Conrad has 22 years of programming experience.<br>C++ is Paul Conrad's favorite programming language.<br>Paul Conrad holds the degree: Bachelor of Science in Computer Science<br><br>
Output for 4.3.0 - 4.4.9, 5.1.3 - 5.6.28, hhvm-3.10.0 - 3.12.0
Programmer Name: Paul Conrad<br>Paul Conrad has 12 years of programming experience.<br>C++ is Paul Conrad's favorite programming language.<br>Paul Conrad holds the degree: Bachelor of Science in Computer Science<br><br>Programmer Name: Paul Conrad<br>Paul Conrad has 22 years of programming experience.<br>C++ is Paul Conrad's favorite programming language.<br>Paul Conrad holds the degree: Bachelor of Science in Computer Science<br><br>
Output for 5.0.0 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/BKBOm on line 4 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/BKBOm on line 5 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/BKBOm on line 6 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/BKBOm on line 7 Programmer Name: Paul Conrad<br>Paul Conrad has 12 years of programming experience.<br>C++ is Paul Conrad's favorite programming language.<br>Paul Conrad holds the degree: Bachelor of Science in Computer Science<br><br>Programmer Name: Paul Conrad<br>Paul Conrad has 22 years of programming experience.<br>C++ is Paul Conrad's favorite programming language.<br>Paul Conrad holds the degree: Bachelor of Science in Computer Science<br><br>