![]() |
Main /
PHPConvert PHP4? to PHP 5.POST VARSThere are very few articles on how to do this. The main changes are these: * $HTTP_POST_VARS should become $_POST * $HTTP_GET_VARS => $_GET * $HTTP_COOKIE_VARS => $_COOKIE * $HTTP_SERVER_VARS => $_SERVER * $HTTP_FILES_VARS => $_FILES * $HTTP_ENV_VARS => $_ENV * $HTTP_REQUEST_VARS => $_REQUEST * $HTTP_SESSION_VARS => $_SESSION The deprecation of the old $HTTP_*_VARS arrays (which need to be indicated as global when used inside a function or method). The following autoglobal arrays were introduced in PHP » 4.1.0. They are: $_GET, $_POST, $_COOKIE, $_SERVER, $_FILES, $_ENV, $_REQUEST, and $_SESSION. The older $HTTP_*_VARS arrays, such as $HTTP_POST_VARS, still exist and have since PHP 3. As of PHP 5.0.0, the long PHP predefined variable arrays may be disabled with the register_long_arrays directive. Also, external variables are no longer registered in the global scope by default. In other words, as of PHP » 4.2.0 the PHP directive register_globals is off by default in php.ini sometimes you see this in PHP4?:
I think to fix this, use:
But here I'm not sure if you would have to check $_GET and $_POST, e.g. Object ModelPassed by Reference This is an important change. In PHP4?, everything was passed by value, including objects. This has changed in PHP5? -- all objects are now passed by reference. PHP Code:$joe = new Person(); $joe->sex = 'male'; $betty = $joe; $betty->sex = 'female'; echo $joe->sex; // Will be 'female' The above code fragment was common in PHP4?. If you needed to duplicate an object, you simply copied it by assigning it to another variable. But in PHP5? you must use the new clone keyword. Note that this also means you can stop using the reference operator (&). It was common practice to pass your objects around using the & operator to get around the annoying pass-by-value functionality in PHP4?. Useful Links
To read UTF-8 chars from a UTF-8 mysql dbDo this once after you open the connection: mysql_query("SET NAMES 'utf8'"); |