【发布时间】:2018-09-15 21:34:19
【问题描述】:
这是一个非常奇怪的错误,我正在尝试修复它但没有成功。 我正在尝试检查链接是否包含字符串:
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
echo $actual_link;
输出是:
http://xxx.xxx.xxx.xxx/plesk-site-preview/***********.com/xxx.xxx.xxx.xxx/
然后:
if(strstr($actual_link,"plesk-site-preview") ){
echo"<meta name='robots' content='noindex'>";
}
问题是尽管plesk-site-preview 包含在http://xxx.xxx.xxx.xxx/plesk-site-preview/***********.com/xxx.xxx.xxx.xxx/ 中,但strstr 返回false。
我该如何解决这个错误?
编辑:
我在if(strstr($actual_link,"plesk-site-preview") ){ 之前插入了以下行用于测试目的:
$actual_link='http://xxx.xxx.xxx.xxx/plesk-site-preview/***********.com/xxx.xxx.xxx.xxx/';
现在代码可以运行了!似乎在 IF 语句之前分配给变量 $actual_link 的字符串丢失了。
【问题讨论】:
-
试试
if(strstr($actual_link,"plesk-site-preview") !== FALSE ){ -
@NineBerry 我已插入您的代码,但错误仍然存在!请注意,我的代码是准确的,
echo $actual_link;和IF语句之间没有更多代码行。 -
你找到这个问题的答案了吗?
-
@Mawg,不,我无法修复此错误。
-
您是否尝试使用
!== False检查结果?这应该工作
标签: php html string url strstr