我对PHP完全一无所知,并试图将其添加到任何地方。
直接访问/blog-1/index.html
应该让我重定向到/blog-2/index.html
,或者至少这个想法.
<?php
global $url = "/blog-1/index.html";
if ($_SERVER['HTTP_REFERER'] == global $url) {
header('Location: /blog-2/index.html');
exit();
}
?>
我一直.
解析错误:语法错误,意外的'=',期待,‘或’;
任何帮助都是非常感谢的。谢谢!
发布于 2017-11-11 06:02:01
这应该是
<?php
global $url = "/blog-1/index.html"; //no need of global here
if ($_SERVER['HTTP_REFERER'] == $url)
{
header('Location: /blog-2/index.html');
exit();
}
?>
if ($_SERVER['HTTP_REFERER'] == global $url) {
,global $url
是罪魁祸首
发布于 2017-11-11 06:08:46
第一个错误:在您编写的这段代码中,使用了全局$url,为什么使用。这个定义不需要像这样定义变量:
$url = "/blog-1/index.html";
第二个错误:创建您的if条件:
if ($_SERVER['HTTP_REFERER'] == $url) {
header('Location: /blog-2/index.html');
exit();
}
当需要使用全局时,例如,您在PHP文件中定义了一个变量,并且不希望将它传递给您的函数。在这种情况下,您可以在PHP中使用全局操作。
发布于 2017-11-11 06:04:28
试着使用以下代码.
<?php
global $url = "/blog-1/index.html";
if ($_SERVER['HTTP_REFERER'] == $url) {
header('Location: /blog-2/index.html');
exit();
}
?>
https://stackoverflow.com/questions/47234894
复制相似问题