3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php public static function realPath2($path) { $isUnixPath = ((strlen($path) === 0) || ($path[0] !== '/')); // Checks if path is relative. if ((strpos($path, ':') === false) && ($isUnixPath === true)) { $path = getcwd() . DIRECTORY_SEPARATOR . $path; } // Resolve path parts (single dot, double dot and double delimiters). $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen'); $absolutes = array(); foreach ($parts as $part) { if (('.' === $part) || ('' === $part)) { continue; } if ('..' === $part) { array_pop($absolutes); } else { $absolutes[] = $part; } } $path = implode(DIRECTORY_SEPARATOR, $absolutes); // Resolve any symlinks. if ((file_exists($path) === true) && (linkinfo($path) > 0)) { $path = readlink($path); } if ($isUnixPath === false) { $path = '/' . $path; } return $path; } echo realPath2('phar://test.phar/a/b/./.././v/../file.txt');
Output for 5.4.0 - 5.4.24
Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /in/0dV75 on line 2
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_PUBLIC in /in/0dV75 on line 2
Process exited with code 255.