艾Q网

标题: PHP识别跳转来源 [打印本页]

作者: admin    时间: 2023-12-6 13:31
标题: PHP识别跳转来源
a.php

<?php
echo "<a href='http://test.im/b.php'>click me</a>";


b.php

<?php
if (isset($_SERVER['HTTP_REFERER'])) {
    var_dump('referer:' . $_SERVER['HTTP_REFERER']);
}else{
    var_dump("not define referer");
}


假设域名为test.im

如果直接运行:http://test.im/b.php

这会输出:

not define referer。

如果运行:http://test.im/a.php

并点击click me,跳转到 http://test.im/b.php,则会输出:

referer:http://test.im/a.php







欢迎光临 艾Q网 (http://js.iqi123.com/bbs/) Powered by Discuz! X3.4