Browser variable not working on include?
Okay so I have a code which says
if (!$num_users || $num_users !== 1 ) {
include_once('../assets/scripts/error.php?error=404');
exit();
}
and it doesn't seem to work, I get the error
failed to open stream: No such file or directory
but if I change the include line to
include_once('../assets/scripts/error.php');
it works. I need to have the开发者_StackOverflow ?error=404
on the end to tell the page to echo out that type of error message. Any help would be grateful!
if (!$num_users || $num_users !== 1 ) {
$error_type = 404;
include_once('../assets/scripts/error.php');
exit();
}
And then in error.php, use the variable $error_type
if it is defined
That's really not how things work. ?error=404 is a parameter that would be passed through an HTTP server while parsing the PHP code. include
literally just takes the contents of the named file and inserts them into the current file right here. You can set a variable $error before the include, and then you can get access to it in the included file.
精彩评论