3v4l.org

run code in 300+ PHP versions simultaneously
<?php function abc($file) { $perms = fileperms($file); if (($perms & 0xC000) == 0xC000) { // Socket $info = 's'; } elseif (($perms & 0xA000) == 0xA000) { // Symbolic Link $info = 'l'; } elseif (($perms & 0x8000) == 0x8000) { // Regular $info = '-'; } elseif (($perms & 0x6000) == 0x6000) { // Block special $info = 'b'; } elseif (($perms & 0x4000) == 0x4000) { // Directory $info = 'd'; } elseif (($perms & 0x2000) == 0x2000) { // Character special $info = 'c'; } elseif (($perms & 0x1000) == 0x1000) { // FIFO pipe $info = 'p'; } else { // Unknown $info = 'u'; } // Owner $info .= (($perms & 0x0100) ? 'r' : '-'); $info .= (($perms & 0x0080) ? 'w' : '-'); $info .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-')); // Group $info .= (($perms & 0x0020) ? 'r' : '-'); $info .= (($perms & 0x0010) ? 'w' : '-'); $info .= (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-')); // World $info .= (($perms & 0x0004) ? 'r' : '-'); $info .= (($perms & 0x0002) ? 'w' : '-'); $info .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-')); return posix_getpwuid(fileowner($file))['name'].' '.posix_getpwuid(filegroup($file))['name'].' '.$info; } echo posix_getpwuid(posix_geteuid())['name'].PHP_EOL.PHP_EOL; $d = '.'; foreach(scandir($d) as $dir) { //echo $dir.': '.substr(sprintf('%o', fileperms($dir)), -4).PHP_EOL; echo $dir.' '.abc($d.'/'.$dir).PHP_EOL; }
Output for 8.3.0 - 8.3.4, 8.3.6
Warning: Trying to access array offset on false in /in/BM3le on line 55 Warning: scandir(): open_basedir restriction in effect. File(.) is not within the allowed path(s): (/tmp:/in:/etc) in /in/BM3le on line 57 Warning: scandir(.): Failed to open directory: Operation not permitted in /in/BM3le on line 57 Warning: scandir(): (errno 1): Operation not permitted in /in/BM3le on line 57 Warning: foreach() argument must be of type array|object, false given in /in/BM3le on line 57
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 Warning: Trying to access array offset on false in /in/BM3le on line 55 Warning: scandir(): open_basedir restriction in effect. File(.) is not within the allowed path(s): (/tmp:/in:/etc) in /in/BM3le on line 57 Warning: scandir(.): Failed to open directory: Operation not permitted in /in/BM3le on line 57 Warning: scandir(): (errno 1): Operation not permitted in /in/BM3le on line 57 Warning: foreach() argument must be of type array|object, false given in /in/BM3le on line 57
Output for 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
Warning: Trying to access array offset on value of type bool in /in/BM3le on line 55 Warning: scandir(): open_basedir restriction in effect. File(.) is not within the allowed path(s): (/tmp:/in:/etc) in /in/BM3le on line 57 Warning: scandir(.): Failed to open directory: Operation not permitted in /in/BM3le on line 57 Warning: scandir(): (errno 1): Operation not permitted in /in/BM3le on line 57 Warning: foreach() argument must be of type array|object, bool given in /in/BM3le on line 57
Output for 8.0.13
Warning: Trying to access array offset on value of type bool in /in/BM3le on line 55 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 . drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 .. drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 bin drwxr-x--x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 boot drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 dev drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 etc drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 home d--------- Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 in drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 lib drwxr-x--x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 lib64 drwxr-x--x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 mnt drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 opt drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 proc dr-xr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 root d--------- Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 run drwxrwxrwt Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 sbin drwxr-x--x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 srv drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 sys dr-xr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 tmp drwxrwxrwt Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 usr drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 var drwxr-xr-x
Output for 8.0.0 - 8.0.12
Warning: Trying to access array offset on value of type bool in /in/BM3le on line 55 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 . drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 .. drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 bin drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 boot drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 dev drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 etc drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 home d--------- Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 in drwxr-x--x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 lib drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 lib64 drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 mnt drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 opt drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 proc dr-xr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 root d--------- Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 run drwxrwxrwt Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 sbin drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 srv drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 sys dr-xr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 tmp drwxrwxrwt Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 usr drwxr-xr-x Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 Warning: Trying to access array offset on value of type bool in /in/BM3le on line 53 var drwxr-xr-x
Output for 7.4.33
Notice: Trying to access array offset on value of type bool in /in/BM3le on line 55 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 . drwxr-xr-x Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 .. drwxr-xr-x Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 bin drwxr-x--x Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 boot drwxr-xr-x Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 dev drwxr-xr-x Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 etc drwxr-xr-x Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 home d--------- Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 in drwxr-xr-x Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 lib drwxr-x--x Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 lib64 drwxr-x--x Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 mnt drwxr-xr-x Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 opt drwxr-xr-x Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 proc dr-xr-xr-x Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 root d--------- Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 run drwxrwxrwt Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 sbin drwxr-x--x Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 srv drwxr-xr-x Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 sys dr-xr-xr-x Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 tmp drwxrwxrwt Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 usr drwxr-xr-x Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 Notice: Trying to access array offset on value of type bool in /in/BM3le on line 53 var drwxr-xr-x
Output for 7.4.26 - 7.4.32
Notice: Trying to access array offset on value of type bool in /in/BM3le on line 55 Warning: scandir(): open_basedir restriction in effect. File(.) is not within the allowed path(s): (/tmp:/in:/etc) in /in/BM3le on line 57 Warning: scandir(.): failed to open dir: Operation not permitted in /in/BM3le on line 57 Warning: scandir(): (errno 1): Operation not permitted in /in/BM3le on line 57 Warning: Invalid argument supplied for foreach() in /in/BM3le on line 57
Output for 5.4.0 - 5.4.45, 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.34, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25
. drwxr-xr-x .. drwxr-xr-x bin drwxr-xr-x boot drwxr-xr-x dev drwxr-xr-x etc drwxr-xr-x home d--------- in drwxr-x--x lib drwxr-xr-x lib64 drwxr-xr-x mnt drwxr-xr-x opt drwxr-xr-x proc dr-xr-xr-x root d--------- run drwxrwxrwt sbin drwxr-xr-x srv drwxr-xr-x sys dr-xr-xr-x tmp drwxrwxrwt usr drwxr-xr-x var drwxr-xr-x
Output for 7.3.33
. drwxr-xr-x .. drwxr-xr-x bin drwxr-x--x boot drwxr-xr-x dev drwxr-xr-x etc drwxr-xr-x home d--------- in drwxr-xr-x lib drwxr-x--x lib64 drwxr-x--x mnt drwxr-xr-x opt drwxr-xr-x proc dr-xr-xr-x root d--------- run drwxrwxrwt sbin drwxr-x--x srv drwxr-xr-x sys dr-xr-xr-x tmp drwxrwxrwt usr drwxr-xr-x var drwxr-xr-x
Output for 7.3.32
. drwxr-xr-x .. drwxr-xr-x bin drwxr-x--x boot drwxr-xr-x dev drwxr-xr-x etc drwxr-xr-x home d--------- in drwxr-x--x lib drwxr-x--x lib64 drwxr-x--x mnt drwxr-xr-x opt drwxr-xr-x proc dr-xr-xr-x root d--------- run drwxrwxrwt sbin drwxr-x--x srv drwxr-xr-x sys dr-xr-xr-x tmp drwxrwxrwt usr drwxr-xr-x var drwxr-xr-x
Output for 5.2.3 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/BM3le on line 53
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.2
<br /> <b>Parse error</b>: syntax error, unexpected '[' in <b>/in/BM3le</b> on line <b>53</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
<br /> <b>Parse error</b>: parse error, unexpected '[' in <b>/in/BM3le</b> on line <b>53</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error in <b>/in/BM3le</b> on line <b>53</b><br />
Process exited with code 255.

preferences:
298.36 ms | 401 KiB | 468 Q