[英]$variable = header location
I can find hundreds of examples of "insert into header location", but I have not found any exaples where the $variable = header
location. 我可以找到数百个“插入标题位置”的例子,但我还没有找到任何
$variable = header
位置的例子。
Is this possible: 这可能吗:
$error=header('Location: http://www.example.com/error.php');
Basicly I had 3 conditions if row not found in mysql. 基本上,如果在mysql中找不到行,我有3个条件。
So I set up the 3 conditions: 所以我设置了3个条件:
if condition1 $error="a statement" if condition1 $ error =“a statement”
if condition2 $error="SELECT data
FROM table
WHERE data
= 'default'"; if condition2 $ error =“SELECT
data
FROM table
WHERE data
='default'”;
if condition3 $error=header('Location: example.com/error.php'); if condition3 $ error = header('Location:example.com/error.php');
and then if($result->num_rows =0) $error 然后if($ result-> num_rows = 0)$ error
In my case $error
could be 3 different things, one of them being "redirect to the error page" but $error=header('Location:blah');
在我的情况下,
$error
可能是3个不同的东西,其中一个是“重定向到错误页面”但是$error=header('Location:blah');
causes 500 server error. 导致500服务器错误。
I altered my code so that I could use header location in the conventional manner, but would still like to know if $var = header
location is possible. 我改变了我的代码,以便我可以以传统方式使用标题位置,但仍然想知道
$var = header
位置是否可行。
The original code that prompted the question has been overwritten, I no longer have it to post. 提示问题的原始代码已被覆盖,我不再需要发布。
Thanks Tom 谢谢汤姆
http://php.net/manual/de/function.header.php http://php.net/manual/de/function.header.php
header() returns void, so, you can write $error=header('Location: http://www.example.com/error.php');
header()返回void,因此,您可以编写
$error=header('Location: http://www.example.com/error.php');
, but it wont do much. ,但它不会做太多。
After header('Location: ...');
header('Location: ...');
you should call exit;
你应该叫
exit;
. 。
You can't assign the 'header' function to anything, as it would always return void. 你不能将'header'函数赋给任何东西,因为它总是会返回void。 A bit useless.
有点无用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.