Question: ```
http://localhost/mc/site-01-up/index.php?c=lorem-ipsum

$address = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$stack = explode('/', $_SERVER["REQUEST_URI"]);
$file = array_pop($stack);
echo $file;

```

result - `index.php?c=lorem-ipsum`

How to get just file name (`index.php`) without `$_GET` variable, using `array_pop` if possible?

Answer: 
I will follow `parse_url()` like below (easy to understand):-

```
<?php
$url = 'http://localhost/mc/site-01-up/index.php?c=lorem-ipsum';

$url=   parse_url($url);
print_r($url); // to check what parse_url() will outputs
$url_path = explode('/',$url['path']); // explode the path part
$file_name =  $url_path[count($url_path)-1]; // get last index value which is your desired result

echo $file_name;
?>

```

Output:- <https://eval.in/606839>

Note:- tested with your given URL. Check for other type of URL's at your end. thanks.
One way of doing it would be to simply get the `basename()` of the file and then strip-out all the Query Part using regex or better still simply do pass the `$_SERVER['PHP_SELF']` result to the `basename()` Function. Both will yield the same result though the 2nd approach seems a little more intuitive. 

```
<?php

    $fileName  = preg_replace("#\?.*$#", "", basename("http://localhost/mc/site-01-up/index.php?c=lorem-ipsum"));
    echo $fileName;  // DISPLAYS: index.php

    // OR SHORTER AND SIMPLER:
    $fileName   = basename($_SERVER['PHP_SELF']);
    echo $fileName;  // DISPLAYS: index.php

```