[PHP] Get the Page Name.

The following code will get the name of the page in php. It is sometimes useful to get name of the page.

        $uri = $_SERVER['REQUEST_URI'];
        $pieces = explode("/", $uri);
        if ($pieces[3] == "upload.php") {
            echo "Page name is upload.php";

My Uri was "/tubesite/admin/upload.php". So when I run explode method, it returned array with three strings.

First string $pieces[0] was an empty string. Second string was tubesite. And so on.

You can check out explode method. It uses to form substrings by splitting it on boundaries formed by the string delimiter http://php.net/manual/en/function.explode.php


Popular posts from this blog

Fatal: LoadModule: error loading module 'mod_sql_mysql.c'

How to hide Android Soft Keyboard