Deprecated features in PHP 5.3.x
PHP 5.3.0 introduces two new error levels: E_DEPRECATED
and E_USER_DEPRECATED
. The
E_DEPRECATED
error level is used to indicate that a
function or feature has been deprecated. The
E_USER_DEPRECATED
level is intended for indicating
deprecated features in user code, similarly to the
E_USER_ERROR
and E_USER_WARNING
levels.
The following is a list of deprecated INI directives. Use of any of these INI
directives will cause an E_DEPRECATED
error to be thrown
at startup.
- define_syslog_variables
- register_globals
- register_long_arrays
- safe_mode
- magic_quotes_gpc
- magic_quotes_runtime
- magic_quotes_sybase
- Comments starting with '#' are now deprecated in .INI files.
Deprecated functions:
- call_user_method() (use call_user_func() instead)
- call_user_method_array() (use call_user_func_array() instead)
- define_syslog_variables()
- dl()
- ereg() (use preg_match() instead)
- ereg_replace() (use preg_replace() instead)
- eregi() (use preg_match() with the 'i' modifier instead)
- eregi_replace() (use preg_replace() with the 'i' modifier instead)
- set_magic_quotes_runtime() and its alias, magic_quotes_runtime()
- session_register() (use the $_SESSION superglobal instead)
- session_unregister() (use the $_SESSION superglobal instead)
- session_is_registered() (use the $_SESSION superglobal instead)
- set_socket_blocking() (use stream_set_blocking() instead)
- split() (use preg_split() instead)
- spliti() (use preg_split() with the 'i' modifier instead)
- sql_regcase()
- mysql_db_query() (use mysql_select_db() and mysql_query() instead)
- mysql_escape_string() (use mysql_real_escape_string() instead)
- Passing locale category names as strings is now deprecated. Use the LC_* family of constants instead.
-
The
is_dst
parameter to mktime(). Use the new timezone handling functions instead.
Deprecated features:
- Assigning the return value of new by reference is now deprecated.
- Call-time pass-by-reference is now deprecated.
- Что нового в PHP 5.3.x ?
- Обратно несовместимые изменения
- Новые возможности
- Изменения в поддержке Windows
- Изменения в модулях SAPI
- Устаревшие функции и возможности в PHP 5.3.x
- Функции и возможности, которые ранее считались устаревшими, а теперь снова возвращены в PHP 5.3.x
- Новые параметры
- Новые функции
- Новые обертки потоков
- Новые фильтры потоков
- Новые константы классов
- Новые методы
- Новые расширения
- Удаленные расширения
- Другие изменения в расширениях
- Новые классы
- Новые глобальные константы
- Изменения в работе с INI-файлами
- Другие изменения
Коментарии
A backward compatibility break which is not documented:
Fatal error: Uncaught exception 'RuntimeException' with message 'Directory name must not be empty.'
This happens with new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $staticPath ) )
If you previously defined register_long_arrays in php.ini and have a lot of code with $HTTP_*_VARS that need to be replaced the following may help on *.nix systems:
sed -i 's/\$HTTP_\(.*\)_VARS/\$_\1/g' filename.php
What this command does is replace all occurrences of $HTTP_*_VARS with their respective $_ counter parts, e.g. $HTTP_COOKIES_VAR to $_COOKIES
To replace alot of files, you might combine it with the find command:
find ./ -name "*.php" -exec sed -i 's/\$HTTP_\(.*\)_VARS/\$_\1/g' {} \;
For other deprecated variables like $HTTP_POST_FILES change your sed arguments:
sed -i 's/\$HTTP_POST_FILES/\$_FILES/g'
Deprecated variables created by the register_long_arrays directive as far as I know are:
$_POST
$_GET
$_SERVER
$_ENV
$_COOKIE
$_SESSION
Correction on my previous note.
sed -i 's/\$HTTP_\(.*\)_VARS/\$_\1/g' {} \;
will screw up multiple instances of $HTTP_*_VARS in the file.
You'll have to use an instance of sed like:
sed -i 's/\$HTTP_SERVER_VARS/\$_SERVER/g'
i.e.
find ./ -name "*.php" -exec sed -i 's/\$HTTP_POST_VARS/\$_POST/g' {} \;
find ./ -name "*.php" -exec sed -i 's/\$HTTP_GET_VARS/\$_GET/g' {} \;
...
for each of the deprecated variables you might have in your files.
It also occurred to me a simple php conversion script would also work:
$search=array(
"/HTTP_SERVER_VARS/",
"/HTTP_POST_VARS/",
"/HTTP_ENV_VARS/",
"/HTTP_GET_VARS/",
"/HTTP_COOKIE_VARS/",
"/HTTP_SESSION_VARS/",
"/HTTP_POST_FILES/");
$replace=array(
"_SERVER",
"_POST",
"_ENV",
"_GET",
"_COOKIES",
"_SESSION","_FILES");
$content=file_get_contents("somefile.php");
$content=preg_replace($search,$replace,$content);
file_put_contents("somefile.php",$content);
add directory recursion functions, ect.
mktime () looks not deprecated
see
mktime
(PHP 4, PHP 5, PHP 7)
mktime — Get Unix timestamp for a date