Nunja, da ich euch nicht langweilen möchte poste ich hier einfach mal den Quellcode des neuen Variablensystems, das vollkommene Kompatibilität mit dem neuen "register-globals"-standard konform ist und gleichermassen mit älteren php-standard-installationen.
Ausserdem gibt es den Parameter $location, in dem man wie in der php.ini die Parse-Reihenfolge bestimmen kann, aber schaut selbst:
function getVar($sVarName, $location) { global $aDB, $oDB; $bFound = NULL; $sValue = NULL; for( $loop = 0 ; $loop < strlen($location) ; $loop++ ) { if( $location[$loop] == 'G' ) // GET { if( isset( $_GET[$sVarName] ) ) { $bFound = true; $sValue = $_GET[$sVarName]; } } else if( $location[$loop] == 'P' ) // POST { if( isset( $_POST[$sVarName] ) ) { $bFound = true; $sValue = $_POST[$sVarName]; } } else if( $location[$loop] == 'C' ) // COOKIE { if( isset( $_COOKIE[$sVarName] ) ) { $bFound = true; $sValue = $_COOKIE[$sVarName]; } } else if( $location[$loop] == 'F' ) // FILES { if( isset( $_FILES[$sVarName] ) ) { $bFound = true; $sValue = $_FILES[$sVarName]; } } else if( $location[$loop] == 'S' ) // SERVER { if( isset( $_SERVER[$sVarName] ) ) { $bFound = true; $sValue = $_SERVER[$sVarName]; } } else if( $location[$loop] == 'E' ) // ENV { if( isset( $_ENV[$sVarName] ) ) { $bFound = true; $sValue = $_ENV[$sVarName]; } else if ( getenv($sVarName) ) // Some servers probably have ENV-Parsing deactivated... { $bFound = true; $sValue = getenv($sVarName); } } else if( $location[$loop] == 'D' ) // DATABASE { list( $sRegister, $sVar ) = explode( "/", $sVarName ); $rValue = $oDB->Query( 'SELECT Value FROM pxp_' . $aDB['key'] . '_config WHERE register=\'' . $sRegister . '\' && name=\'' . $sVar . '\'' ); if( $oDB->NumRows( $rValue ) ) { $bFound = true; $sValue = $oDB->Result( $rValue, 0, 0 ); } } } if(!$bFound) { script_error('Warning: Variable "' . $sVarName . '" not found in ' . $location . '.', ERR_WARNING); return NULL; } return $sValue; }
EDIT: Fehler in der Implementierung: in_array ist case-sensitive, und daher nicht einzusetzen. Code geändert in isset().