在PHP中获取先前的URL路径[重复]

问题描述 投票:0回答:1

我已经尝试过这个<?php $previous_page = $_SERVER['HTTP_REFERER']; ?>

结果为http://localhost/index.php

我怎么只能得到index.php

php http url referrer
1个回答
0
投票
$previous_page = $_SERVER['HTTP_REFERER']; $path_parts = pathinfo($previous_page); $result = $path_parts['basename']; //index.php
https://www.php.net/manual/en/function.pathinfo.php
© www.soinside.com 2019 - 2024. All rights reserved.