3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump(ini_get('open_basedir')); var_dump(ini_set('open_basedir', '/tmp:/in:/etc:/usr')); # doesn't work var_dump(ini_get('open_basedir')); chdir('/tmp'); if (!is_dir('/tmp/a')) mkdir('/tmp/a/b/c/d/e/f/g/',0777,TRUE); else { unlink('foo'); unlink('bar'); } symlink('/tmp/a/b/c/d/e/f/g','foo'); ini_set('open_basedir','/tmp:bar/'); symlink('foo/../../../../../../','bar'); unlink('foo'); symlink('/tmp/','foo'); echo file_get_contents('bar/usr/share/doc/pcre/LICENCE');
Output for 8.0.0
string(13) "/tmp:/in:/etc" bool(false) string(13) "/tmp:/in:/etc" Warning: file_get_contents(bar/usr/share/doc/pcre/LICENCE): Failed to open stream: No such file or directory in /in/75AX0 on line 21
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.24, 7.4.0 - 7.4.13
string(13) "/tmp:/in:/etc" bool(false) string(13) "/tmp:/in:/etc" Warning: file_get_contents(bar/usr/share/doc/pcre/LICENCE): failed to open stream: No such file or directory in /in/75AX0 on line 21
Output for 5.3.11 - 5.3.28, 5.4.0 - 5.4.26, 5.4.28 - 5.4.45
string(0) "" string(0) "" string(18) "/tmp:/in:/etc:/usr" Warning: file_get_contents(bar/usr/share/doc/pcre/LICENCE): failed to open stream: No such file or directory in /in/75AX0 on line 21
Output for 5.4.27
string(0) "" string(0) "" string(18) "/tmp:/in:/etc:/usr" Warning: symlink(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/tmp:bar/) in /in/75AX0 on line 18 Warning: unlink(foo): No such file or directory in /in/75AX0 on line 19 Warning: file_get_contents(bar/usr/share/doc/pcre/LICENCE): failed to open stream: No such file or directory in /in/75AX0 on line 21
Output for 5.3.29
string(0) "" string(0) "" string(18) "/tmp:/in:/etc:/usr" Warning: unlink(foo): No such file or directory in /in/75AX0 on line 19 Warning: symlink(): No such file or directory in /in/75AX0 on line 20 Warning: file_get_contents(bar/usr/share/doc/pcre/LICENCE): failed to open stream: No such file or directory in /in/75AX0 on line 21
Output for 5.3.0 - 5.3.10
string(0) "" string(0) "" string(18) "/tmp:/in:/etc:/usr" Warning: file_get_contents(): open_basedir restriction in effect. File(bar/usr/share/doc/pcre/LICENCE) is not within the allowed path(s): (/tmp:bar/) in /in/75AX0 on line 21 Warning: file_get_contents(bar/usr/share/doc/pcre/LICENCE): failed to open stream: Operation not permitted in /in/75AX0 on line 21
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
bool(false) bool(false) bool(false) Warning: file_get_contents(bar/usr/share/doc/pcre/LICENCE): failed to open stream: No such file or directory in /in/75AX0 on line 21
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
bool(false) bool(false) bool(false) Warning: mkdir() expects at most 2 parameters, 3 given in /in/75AX0 on line 9 Warning: file_get_contents(bar/usr/share/doc/pcre/LICENCE): failed to open stream: No such file or directory in /in/75AX0 on line 21
Output for 4.3.0 - 4.3.1
bool(false) bool(false) bool(false) Warning: mkdir() expects at most 2 parameters, 3 given in /in/75AX0 on line 9 Warning: file_get_contents(bar/usr/share/doc/pcre/LICENCE) [http://www.php.net/function.file-get-contents]: failed to create stream: No such file or directory in /in/75AX0 on line 21