How can I print name of corrent page using php?
How can I print name of corrent page using php ?
echo $corrent_page_name;
R开发者_Go百科esult should be :
index.php
$corrent_page_name = basename($_SERVER['SCRIPT_FILENAME']);
See the PHP manual for $_SERVER
and basename
for more information.
You could also use __FILE__
such as:
$corrent_page_name = basename(__FILE__);
$current_page_name = $_SERVER['PHP_SELF'];
Also, you can use this to include any GET variables in the URL:
$current_page_name = $_SERVER['REQUEST_URI']
EDIT: Sorry. I misunderstood the question. I'll leave this here anyway for future reference.
$current_page_name = end(explode("/",$_SERVER["SCRIPT_FILENAME"]));
精彩评论