从 HTTP 引用中提取文本 [英] Extract Text from HTTP referer
问题描述
我使用以下代码来显示我网站上任何页面的引用链接.我如何修改代码以使其仅显示链接的一部分.即如果我的网站 url 是 www.example.com/?s=printing 我只希望它提取打印.并且只有在格式为 www.example.com/?s=aaa 时才会发生这种情况,而不是在格式为 www.example.com/printing 之类的其他格式时才会发生.
I am using the following code to show the referer link any page on my website. How can i modify the code so that it only shows part of the link. i.e if my website url is www.example.com/?s=printing i only want it to extract printing. And this should only happen if the format is www.example.com/?s=aaa and not if the format is anything else like www.example.com/printing.
代码:
<?php
session_start();
if ( !isset( $_SESSION["origURL"] ) )
$_SESSION["origURL"] = $_SERVER["HTTP_REFERER"];
echo $_SESSION["origURL"]
?>
推荐答案
作为链接的一部分发送到页面的值默认存储在 $_GET
变量中.您的 URL 正在使用 s=printing
.这意味着属性的名称是 s
并且属性的值是 printing
Values that are send to a page as part of a link are stored by default in the $_GET
variable. Your URL is using s=printing
. This means the name of the property is s
and the value of the property is printing
代替您可以使用的所有字符串搜索操作
Instead of all the string search actions you could use
if ( isset($_GET['s']) ) $whatIWant = $_GET['s'];
这篇关于从 HTTP 引用中提取文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!