Home >Backend Development >PHP Tutorial >Things to note when upgrading PHP from 4.0.6 to 4.2.1_PHP Tutorial
I used to make a PHP program for a shopping website, but not long ago, after upgrading PHP from 4.0.6 to 4.2.0, the program changed beyond recognition (what a tragedy...:) But in the end the problem was solved. , someone recently asked me the same question, so I might as well write it down. The main error I encountered was the configuration parameter register_globals=off in PHP.INI. After setting this off, the PHP program will not automatically obtain the value of the variable from the Cookie, Session and the parameters after the "?" number in the page address. , it will not automatically receive the value passed by the form. The reason why this is done by default is to prevent variable poisoning. In previous versions of PHP, this item was not off by default, so there was no problem. The solution is: echo $HTTP_COOKIE_VARS[variable];//Get the value of the cookie echo $HTTP_SESSION_VARS[variable];//Get the value of the session echo $HTTP_POST_VARS[variable];//Get the value passed by the form----- The corresponding form box name echo $HTTP_GET_VARS[variable];//Get the variable value following the question mark in "xxx.php?variable=123456" echo $HTTP_SERVER_VARS[REMOTE_ADDR];//Get the other party's IP address echo $HTTP_POST_FILES[]; //Get the file passed through the form?> I hope everyone will try to use the above complete writing method when writing code in the future (waiting to change the code after making an error is a waste of time and money), because the above writing method no matter when register_globals is set to on There will be no error when it is on or off, and it is more secure.