A. Use the global keyword to import from the application scope.
$var = "01-01-10";
function checkdate(){
global $var;
if("Condition"){
$var = "01-01-11";
}
}
checkdate();
B. Use the $GLOBALS array.
$var = "01-01-10";
function checkdate(){
if("Condition"){
$GLOBALS['var'] = "01-01-11";
}
}
checkdate();
C. Pass the variable by reference.
$var = "01-01-10";
function checkdate(&$funcVar){
if("Condition"){
$funcVar = "01-01-11";
}
}
checkdate($var);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…