I want to make include file with a function, which among other things creates a link to the page itself, with an querystring variable added, how can i get the name of the current php file thus avoiding to have it as a string constant that has to be changed for each different page the include file is included in ?

Regards

Martin Bratbo

I want to make include file with a function, which among other things creates a link to the page itself, with an querystring variable added, how can i get the name of the current php file thus avoiding to have it as a string constant that has to be changed for each different page the include file is included in ?

Regards

Martin Bratbo

$PHP_SELF :cheesy:

Get the name of the current php file

Reply:

hope so it works for you.thank you.

<?php
    $currentFile = $_SERVER["PHP_SELF"];
    $parts = Explode('/', $currentFile);
    echo $parts[count($parts) - 1];
?>

Edited 4 Years Ago by saqlainraza14

You can try this one.hope so it works.

<?php
        $currentFile = $_SERVER["PHP_SELF"];
        $parts = Explode('/', $currentFile);
        echo $parts[count($parts) - 2];   OR echo $parts[count($parts) - 3];
     ?>

Please check and reply me about it.

Edited 4 Years Ago by saqlainraza14: change

This article has been dead for over six months. Start a new discussion instead.