标签: php regex replace preg-replace
如何从$_SERVER['php_self']找到页面标题的名称? 假设$_SERVER显示我的页面:/application/mysite/signup.php。如何选择页面标题signup?
$_SERVER['php_self']
$_SERVER
/application/mysite/signup.php
signup
答案 0 :(得分:11)
您可以使用basename:
basename
echo basename($_SERVER['php_self'], '.php');
或pathinfo:
pathinfo
$pathInfo = pathinfo($_SERVER['php_self']); echo $pathInfo['filename'];