Trying to make compatible PHP4.2 scripts with 4.0.6

From: Date: Wed, 23 Oct 2002 16:46:56 +0000
Subject: Trying to make compatible PHP4.2 scripts with 4.0.6
Groups: php.general 
Request: Send a blank email to php-general+get-121131@lists.php.net to get a copy of this message
<Little_French_Guy_speaking> Hello, I have developped PHP scripts with PHP4.2.x, and I have to make them work on a version 4.0.6, located on a dedicated server (on which I have no administrative rights). There were bugs with some features, and specially the use of the $_POST, $_GET, and $_SERVER vars. The main point is that I do *not* want to modify the scripts code to do this backwards compatibility, except including files to adapt the PHP server to the scripts. [I'm not sure I'm explaining it clearly.] So, I tried to include at the beginning of each script a file to update these three vars with the content of $HTTP_*_VARS when the server version is lower than 4.1 . I also have included a file at the end of session-vars-modifying-scripts to transmit the $_SESSION var (modified by the script) to the $HTTP_SESSION_VARS. This works fine, but only for POST and GET vars. I cannot make sessions vars being updated with this method. (I don't know much about modifying session vars on PHP<4.1 ). The code I use in my PHP4.2 scripts is : <? session_start() ; include('compatibility1.inc.php') ; // Session var setting $_SESSION['test_var'] = 'testsuccessful' ; include('compatibility2.inc.php') ; ?> <? session_start() ; include('compatibility1.inc.php') ; // Session var reading echo $_SESSION['test_var'] ; ?> The code for compatibility1.inc.php is : <? $_POST = $HTTP_POST_VARS ; $_GET = $HTTP_GET_VARS ; // $_SESSION = $HTTP_SESSION_VARS ; // Does not work ?> The code for compatibility2.inc.php is : <? // $HTTP_SESSION_VARS = $_SESSION ; // Does not work // or // foreach( $_SESSION as $key=>$value) { $HTTP_SESSION_VARS[$key]=$value ; } // ==> Does not work either ?> Thank you for helping... </Little_French_Guy_speaking> -- Wallace

« previous php.general (#121131) next »