Search code examples
phphtmlregexurl

URL - Get last part in PHP


I have my url:

http://domain/fotografo/admin/gallery_bg.php

and i want last part of the url:

 gallery_bg.php

but, I do not want to link static, ie, for each page that vistitar I want to get the last part of the url


Solution

  • use following

    <?php
        $link = $_SERVER['PHP_SELF'];
        $link_array = explode('/',$link);
        echo $page = end($link_array);
    ?>