I've included a file in my php script, but for some reason, it can't read a variable I've declared globally, because including the file...
How I've arranged everything:
The include is inside a function
The variable is declared globally (note: even when I declare the variable one line before the include, it can't read the variable (this is in a function though))
The included file reads the variable from a function (in other words: the statement if ($errorcheckonly==true) {} is inside a function in the included file)
Could any of this have an influence on why it's not working?
Code example:
Main file:
$errorcheckonly = true; //declared here or declared beneath, not both
function processOrder() {
$errorcheckonly = true;
include 'passengersform.php'; //forced to only use error checks
}
processOrder();
Included file:
function processtickets () {
echo '<script language="javascript">alert("'.$errorcheckonly.'");</script>';
if ($errorcheckonly==true) { exit; }
}
processtickets();