简体   繁体   English

eregi PHP 中的标头位置有什么问题

[英]What's wrong with header location in eregi PHP

$page=curl_exec ($ch); 

if(eregi('EXP', $page)){
    header("location: https://www.facebook.com");
}

My probleme is with the header location not working我的问题是标题位置不起作用

What exactly isn't working?究竟是什么不起作用? Is it showing an error message or just not forwarding?它是否显示错误消息或只是不转发? Check your regex at regex101.com .regex101.com 上检查您的正则表达式。

eregi() was deprecated and removed so if you're using a more recent version of PHP, it would probably completely error out. eregi() 已被弃用并删除,因此如果您使用的是更新版本的 PHP,它可能会完全出错。 You can try using preg_match() instead.您可以尝试使用preg_match()代替。

I'm not 100% sure if it's case-sensitive, but I've always seen and used Location: with a capital L .我不是 100% 确定它是否区分大小写,但我总是看到并使用Location:大写L

It's also generally a good idea to exit after you use a location redirect header:在使用位置重定向标头后exit通常也是一个好主意:

header("Location: https://www.facebook.com");
exit;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM