I have this piece of code
redirect_loc(index.php);
And the definition for this function is somewhere in a functions file.
function redirect_loc($location=NULL)
{
if($location!=NULL)
{
header("Location:$location");
exit;
}
}
When I pass “index.php” (note the quotes around to specify as a string) it works, however passing index.php gives error The requested URL /indexphp was not found on this server.
Why doesn’t this work when it’s not passed as a string ?
The . acts as concatenation operator . Did you see what the name was of the file it couldn’t find? No
.… It joined the two “strings” (indexandphp) together – it thought that’s what you wanted.