在 PHP 中获取上一个 URL 路径
Get previous URL path in PHP
这个我试过了
<?php $previous_page = $_SERVER['HTTP_REFERER']; ?>
结果是http://localhost/index.php
怎么才能只得到index.php
$previous_page = $_SERVER['HTTP_REFERER'];
$path_parts = pathinfo($previous_page);
$result = $path_parts['basename']; //index.php
这个我试过了
<?php $previous_page = $_SERVER['HTTP_REFERER']; ?>
结果是http://localhost/index.php
怎么才能只得到index.php
$previous_page = $_SERVER['HTTP_REFERER'];
$path_parts = pathinfo($previous_page);
$result = $path_parts['basename']; //index.php