3v4l.org

run code in 300+ PHP versions simultaneously
<?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 git.master, git.master_jit, rfc.property-hooks
<!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(): open_basedir restriction in effect. File(class_lib.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/O3l8L on line 25 Warning: include(class_lib.php): Failed to open stream: Operation not permitted 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>

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
35.21 ms | 402 KiB | 8 Q