Page 1 of 1
How can i get the current pagename?
Posted: Thu Apr 01, 2004 2:41 am
by fastfingertips
I'm interested to store the current page name, how can i do that?
Posted: Thu Apr 01, 2004 2:45 am
by markl999
$_SERVER['PHP_SELF'] ..
or basename($_SERVER{'PHP_SELF']) for JUST the page name (and not it's path).
There's also __FILE__

Posted: Thu Apr 01, 2004 4:19 am
by Pozor
hello,
$_SERVER['PHP_SELF'] shows the file name with the relative path from the host
__FILE__ shows the translated path of the current file
example file on the root folder (www folder or html folder, depends on the provider):
__FILE__ : /home/develop/public_html/test_selfname.php
$_SERVER[PHP_SELF]: /test_selfname.php
to get only the filename you can use this:
Code: Select all
<?php
$result = explode('/',__FILE__);
or
$result = explode('/',$_SERVER['PHP_SELF']);
?>
greez Pozor
Posted: Thu Apr 01, 2004 4:34 am
by twigletmac
To get only the filename from a path, you don't need to explode the string, just use [php_man]basename[/php_man]() like markl999 suggested.
Mac
Posted: Thu Apr 01, 2004 4:37 am
by Pozor
hello,
sorry i was to fast... i didn't read it very properly
I never used this... i'm still learning thanks
greez pozor
edit:
PS: it doesn't matter if you have a string like this: blabla/file.php?var=gugus ?