3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo(){ // sys_get_temp_dir is only available since PHP 5.2.1 // http://php.net/manual/en/function.sys-get-temp-dir.php#94119 if ( !function_exists('sys_get_temp_dir')) { if ($temp = getenv('TMP') ) { if ((!empty($temp)) && (file_exists($temp))) { return realpath($temp); } } if ($temp = getenv('TEMP') ) { if ((!empty($temp)) && (file_exists($temp))) { return realpath($temp); } } if ($temp = getenv('TMPDIR') ) { if ((!empty($temp)) && (file_exists($temp))) { return realpath($temp); } } // trick for creating a file in system's temporary dir // without knowing the path of the system's temporary dir $temp = tempnam(__FILE__, ''); if (file_exists($temp)) { unlink($temp); return realpath(dirname($temp)); } return null; } // use ordinary built-in PHP function // There should be no problem with the 5.2.4 Suhosin realpath() bug, because this line should only // be called if we're running 5.2.1 or earlier return realpath(sys_get_temp_dir()); } echo $foo();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Warning: Undefined variable $foo in /in/pFYfM on line 32 Fatal error: Uncaught Error: Value of type null is not callable in /in/pFYfM:32 Stack trace: #0 {main} thrown in /in/pFYfM on line 32
Process exited with code 255.
Output for 7.4.26 - 7.4.33
Notice: Undefined variable: foo in /in/pFYfM on line 32 Fatal error: Uncaught Error: Function name must be a string in /in/pFYfM:32 Stack trace: #0 {main} thrown in /in/pFYfM on line 32
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.25
Fatal error: Uncaught Error: Function name must be a string in /in/pFYfM:32 Stack trace: #0 {main} thrown in /in/pFYfM on line 32
Process exited with code 255.
Output for 5.2.3 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Function name must be a string in /in/pFYfM on line 32
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.2
<br /> <b>Fatal error</b>: Function name must be a string in <b>/in/pFYfM</b> on line <b>32</b><br />
Process exited with code 255.
Output for 4.4.5 - 4.4.9
<br /> <b>Fatal error</b>: Call to undefined function: () in <b>/in/pFYfM</b> on line <b>32</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
<br /> <b>Fatal error</b>: Call to undefined function: () in <b>/in/pFYfM</b> on line <b>32</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<br /> <b>Fatal error</b>: Call to undefined function: () in <b>/in/pFYfM</b> on line <b>32</b><br />

preferences:
286.56 ms | 401 KiB | 464 Q