Reputation: 141
I am trying to integrate a website from a partner of my company, and I running into this line here:
header("Location: field/index.php", overwrite);
I browsed the PHP manual of header()
function, but can't find a parameter called overwrite
.
Can someone give me any clue?
Upvotes: 2
Views: 1672
Reputation: 146191
It (overwrite) could be a constant, for example
define('overwrite', true);
header("Location: field/index.php", overwrite);
In this case overwrite
represents Boolean true
and which is being used to replace a previous header.
Though, constants should be declared using uppercase letters but it doesn't throw any errors if someone uses lowercase letters instead. Recommended way to define a constant is
defined('OVERWRITE') or define('OVERWRITE', TRUE);
It's worth mentioning that, any constant defined this way is available globally, throughout the script/application and basically developers define constants at the very beginning of script or an application and it could be defined in a different file (which is included/executed on start up) so, you may don't see it in the current script.
Upvotes: 1
Reputation: 18891
There are three parameters for PHP header()
:
"Location: field/index.php"
here)http_response_code
: Used to force the HTTP response codeFrom the documentation:
The optional replace parameter indicates whether the header should replace a previous similar header [...] By default it will replace
The overwrite
value in your code is invalid, because it is an unquoted string where a boolean value should be. Using header("Location: field/index.php", true);
is correct, but because true
is default, you only need header("Location: field/index.php")
.
Upvotes: 1
Reputation: 141839
The second parameter (replace) means the same thing as overwrite. If you see the line:
header("Location: field/index.php", overwrite);
That is most likely not valid (it is technically valid if overwrite is a constant). It should be:
header("Location: field/index.php", true);
Upvotes: 3
Reputation: 1963
https://www.php.net/manual/en/function.header.php
The php site is good for this kind of question. The second param just tells it whether or not to "overwrite" (replace) a value that has already been set.
Note that the value passed into the function doesn't necessarily have anything to do with the name of the parameter. They are simply used in order. Here, overwrite
must be a variable set somewhere else although it's surprising it doesn't have the typical $ in front of it marking it as a variable in PHP. The variable overwrite is evaluated and its value is passed as the second parameter in the header function.
Upvotes: 0