3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = '~/test/../test2/test3/../file.php'; // Fake home setting. putenv( 'HOME=/Users/alain' ); function get_home_directory() { // Unix. $home = getenv( 'HOME' ); if ( ! empty( $home ) ) { return rtrim( $home, '/' ); } // Windows. if ( ! empty( $_SERVER['HOMEDRIVE'] ) && ! empty( $_SERVER['HOMEPATH'] ) ) { $home = $_SERVER['HOMEDRIVE'] . $_SERVER['HOMEPATH']; return rtrim( $home, '\\/' ); } return '~'; } function get_normalized_path($path) { return array_reduce(explode('/', $path), function( $a = '/', $b ) { switch ( $b ) { case '': case '.': return $a; case '..': return dirname( $a ); case '~': return get_home_directory(); default: return preg_replace("/\/+/", "/", "$a/$b"); } } ); } echo $test . PHP_EOL; echo get_normalized_path( $test ) . PHP_EOL;
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Optional parameter $a declared before required parameter $b is implicitly treated as a required parameter in /in/9Ga8c on line 23 ~/test/../test2/test3/../file.php /Users/alain/test2/file.php

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
27.56 ms | 405 KiB | 5 Q