PHP 5.3 starts with a better transition to future versions of PHP (PHP6), marking functions that are no longer supported in the future as DEPRECATED. Using these functions in your code will relentlessly display a warning message in the page: "Using outdated functions ..." and so on.
So how to face the future, let the existing PHP program smooth to the next generation of PHP engine transition?
Configuration file Migration
Starting with PHP 5.3, some of the configuration files in php.ini will display outdated warnings when PHP executes, which will no longer exist in PHP6 and will be turned off.
1.define_syslog_variables
2.register_globals
3.register_long_arrays
4.safe_mode
5.magic_quotes_gpc
6.magic_quotes_runtime
7.magic_quotes_sybase
function migration
The main function migration involved is as follows:
Delete a function Define_syslog_variables reference
Delete a reference to a function define_syslog_variables
The variable $LOG _err, $LOG _user, etc. with constant log_user, Log_user, ... Alternative
Ereg, Eregi function replaces with preg_match function? function declarations for these functions
int Ereg (string $pattern, String $string [, Array & $regs]) int eregi (string $pattern, String $strin g [, Array & $regs]) int Preg_match (string $pattern, String $subject [, Array & $matches [, int $flag s [, Int. $offset]])? Although the first parameter of all three is a string, it represents a regular expression. But Preg_match uses the PCRE (Perl-compatible regular expression syntax): Both ends of the regular expression are bounded by a symbol, such as "/pattern/" or "#pattern #"
? Eregi is a slightly case-sensitive match, converted to Preg_match, the first parameter, with pcre parameters to be slightly case-sensitive, such as: "/pattern/i" or "#pattern #i"
? The third parameter of the two returns a different structure of the matching data. The third parameter of Ereg, after the call is finished, returns an array of strings, each of which is the complete matching string and each sub-matching string. Preg_match returns a two-dimensional array, which is equivalent to a string in an array of ereg strings, where Preg_match is an array, preserving the matching values and matching positions, respectively.
? If multiple matches are to be made, PHP provides the Preg_match_all function, and the return value of its third parameter is a three-dimensional array;
ereg_replace, the Eregi_replace function is replaced with the Preg_replace function or the Str_replace function.? Similar to the previous Ereg replace with Preg_match, the first argument is converted, and a symbol is added to the head and tail, such as: "/pattern/" or "#pattern #", ...
Eregi_replace to Preg_replace, add the regular expression parameter after the first argument. such as: "/pattern/i" or "#pattern #i", ...
? If the first parameter of Ereg_replace is not a regular expression, you can replace it with str_replace directly.
Split, Spliti function with explode or preg_split function insteadSplit splits the string, and if you don't need a regular expression, replacing it with explode is best, but the fastest
For the use of regular expressions to slice a string, use the Preg_split function instead. The substitution process is similar to ereg/ereg_replace, just a fuss in the first regular expression argument, with the split regular expression preceded and followed by a PCRE separator symbol.
mysql_db_query functions Replace with mysql_select_db and mysql_query functionsMysql_db_query is no longer supported in future versions
Convert it to two calls, using mysql_select_db to select the database and execute the SQL query with mysql_query
mysql_escape_string function substitution with mysql_real_escape_string function
? mysql_escape_string future versions no longer support
? using Mysql_real_escape_string Overrides
session_register function, session_unregister,session_is_registered function with $_session global variable substitution? These three session-related functions are no longer supported in the future
The function is equivalent to manipulating the global array $_session directly. You can assign values directly to the array or perform the corresponding unset to implement the relevant functions
Check out obsolete functions in code
The following script can be used to find outdated PHP functions in the code tree
#!/bin/shopts= "-RHW"; verbose=0while [$#-gt 0]; do Case $ in -V) verbose=1; shift; -Q) verbose=0; shift; -*) opts= "$OPTS $"; shift; *) break;;; Esacdoneif [$#-eq 0]; then echo "Usage $ [-v]" exit 1fi[$verbose-eq 0] && opts= "$OPTS-L" deprecated= "Call_user_method C All_user_method_array define_syslog_variables DL Set_magic_quotes_runtime magic_quotes_runtime Set_socket_blocking sql_regcase mysql_db _query mysql_escape_string Session_register Session_unregister Session_is_registered eregi? Eregi?_replace Spliti? " opts= "$OPTS--include=*.inc--include=*.php--include=*.php5" for item in $DEPRECATED; do echo "##### find deprecated Item: $item in $: #####" grep $OPTS-E "$item \s*$" $* grep $OPTS-E "$it Em\s*\ ("$* echo" "Done+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++fix" Ereg is Deprecated ' errors in PHP 5.3If upgraded to PHP 5.3, chances is high "re going to run into a few warnings or depre cated function Messages. An example is the Ereg family of functions, which be gone for good, as they were slower and felt less familiar than the A Lternative perl-compatible Preg family. To migrate Ereg (): Ereg (' \. ( [^\.] *$) ', $this->file_src_name, $extension);