How can i get the current pagename?
Moderator: General Moderators
-
fastfingertips
- Forum Contributor
- Posts: 242
- Joined: Sun Dec 28, 2003 1:40 am
- Contact:
How can i get the current pagename?
I'm interested to store the current page name, how can i do that?
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:
greez Pozor
$_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
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK