获取php中超链接的源文件名
Get the source file name of hyperlink in php
我在 php 中有一个代码,许多网页都在调用它。现在我想知道点击超链接的 .php 名称。
示例:
file1.php
<a href="file2.php?id=2">Click this link</a>
现在单击 "Click this link" file2.php 将打开。
我想在控制传递给 file2.php 时确定 file1.php 名称。
查看推荐人:$_SERVER['HTTP_REFERER']
if set OR
添加javaScript:
--
<a href="file2.php?id=2" onClick="location=this.href+'&ref='+escape(location.href)">Click this link</a>
$_SERVER 是一个 PHP 超级全局变量,它包含有关 headers、路径和脚本位置的信息。
echo $_SERVER['HTTP_REFERER'];
Returns the complete URL of the current page (not reliable because not
all user-agents support it)
在 file2.php 内,执行此操作:
<?php
$referrer_file = $_SERVER['HTTP_REFERER'];
echo $referrer_file;
?>
我在 php 中有一个代码,许多网页都在调用它。现在我想知道点击超链接的 .php 名称。
示例:
file1.php
<a href="file2.php?id=2">Click this link</a>
现在单击 "Click this link" file2.php 将打开。 我想在控制传递给 file2.php 时确定 file1.php 名称。
查看推荐人:
$_SERVER['HTTP_REFERER']
if set OR添加javaScript:
--
<a href="file2.php?id=2" onClick="location=this.href+'&ref='+escape(location.href)">Click this link</a>
$_SERVER 是一个 PHP 超级全局变量,它包含有关 headers、路径和脚本位置的信息。
echo $_SERVER['HTTP_REFERER'];
Returns the complete URL of the current page (not reliable because not all user-agents support it)
在 file2.php 内,执行此操作:
<?php
$referrer_file = $_SERVER['HTTP_REFERER'];
echo $referrer_file;
?>