3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php include('/etc/profile'); $myfile = fopen("/tmp/test.txt", "w") or die("Unable to open file!"); $txt = "John Doe\n"; fwrite($myfile, $txt); $txt = "Jane Doe\n"; fwrite($myfile, $txt); fclose($myfile); // current directory echo getcwd() . "\n"; chdir('/tmp'); // current directory echo getcwd() . "\n"; $dir = '/etc/'; $files1 = scandir($dir); $files2 = scandir($dir, 1); print_r($files1); print_r($files2);
Output for 5.6.30, hhvm-3.15.4 - 3.22.0, 7.0.0 - 7.2.9
# /etc/profile #Set our umask umask 022 # Set our default path PATH="/usr/local/sbin:/usr/local/bin:/usr/bin" export PATH # Load profiles from /etc/profile.d if test -d /etc/profile.d/; then for profile in /etc/profile.d/*.sh; do test -r "$profile" && . "$profile" done unset profile fi # Source global bash config if test "$PS1" && test "$BASH" && test -z ${POSIXLY_CORRECT+x} && test -r /etc/bash.bashrc; then . /etc/bash.bashrc fi # Termcap is outdated, old, and crusty, kill it. unset TERMCAP # Man is much better than us at figuring this out unset MANPATH / /tmp Array ( [0] => . [1] => .. [2] => arch-release [3] => bash.bash_logout [4] => bash.bashrc [5] => crypttab [6] => fstab [7] => gai.conf [8] => group [9] => gshadow [10] => hhvm [11] => host.conf [12] => hosts [13] => inputrc [14] => issue [15] => ld.so.cache [16] => ld.so.conf [17] => ld.so.conf.d [18] => locale.gen [19] => localtime [20] => machine-id [21] => motd [22] => mtab [23] => nscd.conf [24] => nsswitch.conf [25] => pacman.d [26] => passwd [27] => php.ini [28] => php_archive.ini [29] => profile [30] => profile.d [31] => protocols [32] => resolv.conf [33] => rpc [34] => securetty [35] => services [36] => shadow [37] => shells [38] => skel ) Array ( [0] => skel [1] => shells [2] => shadow [3] => services [4] => securetty [5] => rpc [6] => resolv.conf [7] => protocols [8] => profile.d [9] => profile [10] => php_archive.ini [11] => php.ini [12] => passwd [13] => pacman.d [14] => nsswitch.conf [15] => nscd.conf [16] => mtab [17] => motd [18] => machine-id [19] => localtime [20] => locale.gen [21] => ld.so.conf.d [22] => ld.so.conf [23] => ld.so.cache [24] => issue [25] => inputrc [26] => hosts [27] => host.conf [28] => hhvm [29] => gshadow [30] => group [31] => gai.conf [32] => fstab [33] => crypttab [34] => bash.bashrc [35] => bash.bash_logout [36] => arch-release [37] => .. [38] => . )