开发者

How can I print name of corrent page using php?

开发者 https://www.devze.com 2023-01-24 17:27 出处:网络
How can I print name of corrent page using php ? echo $corrent_page_name; R开发者_Go百科esult should be :

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"]));

0

精彩评论

暂无评论...
验证码 换一张
取 消