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; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta> <title>Learning OOP Constructor </title> <?php include("class_lib.php"); ?> </head>` <body> <?php // 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(); ?> </body> </html>
Output for 5.1.3 - 5.6.28, 7.0.0 - 7.1.0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta> <title>Learning OOP Constructor </title> Warning: include(class_lib.php): failed to open stream: No such file or directory in /in/O3l8L on line 25 Warning: include(): Failed opening 'class_lib.php' for inclusion (include_path='.:') in /in/O3l8L on line 25 </head>` <body> <br>Debbie's full name: Debbie B<br>Lisa's full name: Lisa L </body> </html>
Output for hhvm-3.12.0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta> <title>Learning OOP Constructor </title> Warning: File not found: class_lib.php in /in/O3l8L on line 25 </head>` <body> <br>Debbie's full name: Debbie B<br>Lisa's full name: Lisa L </body> </html>
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.1.0 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/O3l8L on line 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta> <title>Learning OOP Constructor </title> Warning: include(class_lib.php): failed to open stream: No such file or directory in /in/O3l8L on line 25 Warning: include(): Failed opening 'class_lib.php' for inclusion (include_path='.:') in /in/O3l8L on line 25 </head>` <body> <br>Debbie's full name: Debbie B<br>Lisa's full name: Lisa L </body> </html>
Output for 5.0.0 - 5.0.5
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/O3l8L on line 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta> <title>Learning OOP Constructor </title> Warning: main(class_lib.php): failed to open stream: No such file or directory in /in/O3l8L on line 25 Warning: main(): Failed opening 'class_lib.php' for inclusion (include_path='.:') in /in/O3l8L on line 25 </head>` <body> <br>Debbie's full name: Debbie B<br>Lisa's full name: Lisa L </body> </html>
Output for 4.3.2 - 4.4.9
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta> <title>Learning OOP Constructor </title> Warning: main(class_lib.php): failed to open stream: No such file or directory in /in/O3l8L on line 25 Warning: main(): Failed opening 'class_lib.php' for inclusion (include_path='.:') in /in/O3l8L on line 25 </head>` <body> <br>Debbie's full name: Debbie B<br>Lisa's full name: </body> </html>
Output for 4.3.0 - 4.3.1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta> <title>Learning OOP Constructor </title> Warning: main(class_lib.php) [http://www.php.net/function.main]: failed to create stream: No such file or directory in /in/O3l8L on line 25 Warning: main() [http://www.php.net/function.main]: Failed opening 'class_lib.php' for inclusion (include_path='.:') in /in/O3l8L on line 25 </head>` <body> <br>Debbie's full name: Debbie B<br>Lisa's full name: </body> </html>