0

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

9
Contributors
9
Replies
32
Views
12 Years
Discussion Span
Last Post by ishan1211
0

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:

-1

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 by saqlainraza14

0

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 by saqlainraza14: change

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.