One way to do this would be to simply get the basename()file and then cross out the entire part of the query using a regular expression, or better yet, just pass the result $_SERVER['PHP_SELF']to a function basename(). Both give the same result, although the second approach seems a little more intuitive.
<?php
$fileName = preg_replace("#\?.*$#", "", basename("http://localhost/mc/site-01-up/index.php?c=lorem-ipsum"));
echo $fileName;
$fileName = basename($_SERVER['PHP_SELF']);
echo $fileName;
source
share