Is there a way, within a PHP script, to pick up the name of the web page that the script is being run on?
Pick up page name in PHP?
Collapse
X
-
Tags: None
-
bonski,
Thanks for the reply.
That looks like it will return the name of the script file in which the PHP code resides. What I'm looking for is to get access to the name of the web page from within which that script is included.
That is, let's say I have a page named "MyPage.php " and within that page I do an include "MyPHPFunctions .php". WHat I want to access, from within MyPHPFunctions. php, the name of MyPage.php. Kind of like getting the "parent" of the current include file.
- RogerComment
-
Originally posted by RogerInHawaiibonski,
Thanks for the reply.
That looks like it will return the name of the script file in which the PHP code resides. What I'm looking for is to get access to the name of the web page from within which that script is included.
That is, let's say I have a page named "MyPage.php " and within that page I do an include "MyPHPFunctions .php". WHat I want to access, from within MyPHPFunctions. php, the name of MyPage.php. Kind of like getting the "parent" of the current include file.
- Roger
[PHP]$scriptname=get env("SCRIPT_NAM E");
$viewpage = basename($scrip tname);
echo $viewpage.'<br> ';[/PHP]
just give a try... bonskiComment
-
If I'm understanding you correctly, this should also work.
[code=php]
//Note. this will return the entire URL
// including any GET data.
$pageURL = $_SERVER['PHP_SELF'];
[/code]
Included files are essentially inlined into the file that calls the include command, so if you include 'myFunctions.ph p' into 'myPage.php' the code from 'myFunctions.ph p' is being executed as a part of 'myPage.php'.Comment
Comment