3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo \getcwd(); \mkdir('/tmp/foo'); \chdir('/tmp/foo'); \rmdir('/tmp/foo'); // Outputs: / (incorrect) echo \getcwd(); echo PHP_EOL; // Outputs: false (correct) echo \realpath(''); echo PHP_EOL; // Crash echo \realpath('.'); echo \realpath('./');
Output for 7.4.26, 8.1.13
/ Warning: mkdir(): File exists in /in/jWhgB on line 5 Warning: realpath(): open_basedir restriction in effect. File(.) is not within the allowed path(s): (/tmp:/in:/etc) in /in/jWhgB on line 18 Warning: realpath(): open_basedir restriction in effect. File(.) is not within the allowed path(s): (/tmp:/in:/etc) in /in/jWhgB on line 19
Output for 7.3.33, 7.4.27 - 7.4.33, 8.0.14 - 8.0.19, 8.0.22 - 8.0.26, 8.1.0 - 8.1.7, 8.1.9 - 8.1.12
/ Warning: mkdir(): File exists in /in/jWhgB on line 5 Warning: rmdir(/tmp/foo): Directory not empty in /in/jWhgB on line 7 /tmp/foo /tmp/foo /tmp/foo/tmp/foo
Output for 7.1.25, 7.2.0 - 7.2.33, 7.3.2 - 7.3.31, 7.4.0 - 7.4.25, 8.0.0 - 8.0.12, 8.0.20 - 8.0.21, 8.1.8
/ Warning: realpath(): open_basedir restriction in effect. File(.) is not within the allowed path(s): (/tmp:/in:/etc) in /in/jWhgB on line 18 Warning: realpath(): open_basedir restriction in effect. File(.) is not within the allowed path(s): (/tmp:/in:/etc) in /in/jWhgB on line 19
Output for 7.3.32, 8.0.13
/ ..
Output for 7.3.1
/ php-7.3.1: /root/root/php-7.3.1/Zend/zend_virtual_cwd.c:762: tsrm_realpath_r: Assertion `i < MAXPATHLEN' failed.
Process exited with code 134.
Output for 7.3.0
/ php-7.3.0: /root/root/php-7.3.0/Zend/zend_virtual_cwd.c:762: tsrm_realpath_r: Assertion `i < MAXPATHLEN' failed.
Process exited with code 134.

preferences:
72.71 ms | 414 KiB | 5 Q