3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (!function_exists("str_ends_with")) { function str_ends_with($haystack, $needle) { return strrpos($haystack, $needle) === strlen($haystack) - strlen($needle); } } $urls = [ "https://www.example.gov.us/directory_1/directory_2/directory_3/index.php", "https://www.example.gov.us/directory_1/directory_2/directory_3/index", "https://www.example.gov.us/directory_1/directory_2/directory_3/" ]; foreach ($urls as $url) { printf( "From %s, got '%s'%s", $url, str_ends_with($url, "/") ? "" : basename($url), PHP_EOL ); }
Output for git.master, git.master_jit, rfc.property-hooks
From https://www.example.gov.us/directory_1/directory_2/directory_3/index.php, got 'index.php' From https://www.example.gov.us/directory_1/directory_2/directory_3/index, got 'index' From https://www.example.gov.us/directory_1/directory_2/directory_3/, got ''

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:
29.01 ms | 406 KiB | 5 Q