3v4l.org

run code in 300+ PHP versions simultaneously
<?php for ($i = 4; $i <= 6; print $i ++); $i=4; $j=30; $k=0; $k=$j++/$i++; echo $i . ' ' . $j . ' ' . $k . ' ' ."\r\n"; $aa = 10; echo 'Value of a = $a'."\r\n"; $a = array( 1=> 'one', 2 => 'two', 3 => 'three'); unset( $a[2] ); print_r($a[2]); print_r($a[3]); $great = 'fantastic'; echo "This is {$great}"; $var1="a"; $$var1="b"; echo "$var1 $a"; class Insurance{ function clsNAme(){ echo get_class($this); } } print 5+2 * 4+6; $cl = new Insurance(); $cl->clsName(); Insurance::clsName(); var_dump (3*4); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.example.com/"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); $var = "testing module"; $statement = 'This is a $var'; echo ($statement); $var = "testing module"; $statement = "This is a $var"; echo ($statement); $arr = array("foo","bar","baz"); for ( $i = 0; $i < count($arr); $i++){ $item = $arr[$i]; } echo "<pre>"; print_r($item); echo "</pre><br/>\r\n"; $a = 3; print '$a'."\r\n"; echo '$a'."\r\n"; print "$a\r\n"; echo "$a\r\n"; $array = array(array(141,151,161), 2, 3, array(101, 202, 303)); function DisplayArray($array) { foreach ($array as $value) { if (is_array($value)) { DisplayArray($value); } else { echo $value . " "; } } } DisplayArray($array); echo 0x10; ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
4565 31 7.5 Value of a = $a Warning: Undefined array key 2 in /in/HAZbY on line 14 threeThis is fantastica b19Insurance Fatal error: Uncaught Error: Non-static method Insurance::clsNAme() cannot be called statically in /in/HAZbY:29 Stack trace: #0 {main} thrown in /in/HAZbY on line 29
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 4565 31 7.5 Value of a = $a Warning: Undefined array key 2 in /in/HAZbY on line 14 threeThis is fantastica b19Insurance Fatal error: Uncaught Error: Non-static method Insurance::clsNAme() cannot be called statically in /in/HAZbY:29 Stack trace: #0 {main} thrown in /in/HAZbY on line 29
Process exited with code 255.
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
4565 31 7.5 Value of a = $a Notice: Undefined offset: 2 in /in/HAZbY on line 14 threeThis is fantastica b19Insurance Deprecated: Non-static method Insurance::clsNAme() should not be called statically in /in/HAZbY on line 29 Fatal error: Uncaught Error: Using $this when not in object context in /in/HAZbY:23 Stack trace: #0 /in/HAZbY(29): Insurance::clsNAme() #1 {main} thrown in /in/HAZbY on line 23
Process exited with code 255.
Output for 7.3.32 - 7.3.33
4565 31 7.5 Value of a = $a threeThis is fantastica b19Insurance Fatal error: Uncaught Error: Using $this when not in object context in /in/HAZbY:23 Stack trace: #0 /in/HAZbY(29): Insurance::clsNAme() #1 {main} thrown in /in/HAZbY on line 23
Process exited with code 255.
Output for 7.0.0 - 7.0.20
4565 31 7.5 Value of a = $a Notice: Undefined offset: 2 in /in/HAZbY on line 14 threeThis is fantastica b19Insurance Deprecated: Non-static method Insurance::clsNAme() should not be called statically in /in/HAZbY on line 29 Notice: Undefined variable: this in /in/HAZbY on line 23 Insuranceint(12) Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/HAZbY:32 Stack trace: #0 {main} thrown in /in/HAZbY on line 32
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
4565 31 7.5 Value of a = $a Notice: Undefined offset: 2 in /in/HAZbY on line 14 threeThis is fantastica b19Insurance Strict Standards: Non-static method Insurance::clsNAme() should not be called statically in /in/HAZbY on line 29 Notice: Undefined variable: this in /in/HAZbY on line 23 Insuranceint(12) Fatal error: Call to undefined function curl_init() in /in/HAZbY on line 32
Process exited with code 255.

preferences:
163.45 ms | 402 KiB | 213 Q