PHP 5.6.0 released

Fonctionnalités obsolètes en PHP 5.3.x

PHP 5.3.0 introduit deux nouveaux niveaux d'erreur : E_DEPRECATED et E_USER_DEPRECATED. Le niveau d'erreur E_DEPRECATED sert à indiquer qu'une fonctionnalité est obsolète, et E_USER_DEPRECATED sert à la même chose pour les fonctions utilisateur, tout comme E_USER_ERROR et E_USER_WARNING .

Voici une liste des directives INI obsolètes : si l'une d'entre elle est activée, elle va émettre une alerte d'obsolescence (E_DEPRECATED) au démarrage.

Fonctions obsolètes :

Fonctionnalités obsolètes :

  • Assigner la valeur de retour de l'opérateur new par référence est obsolète.
  • Le passage par référence à l'appel est maintenant obsolète.
add a note add a note

User Contributed Notes 3 notes

up
0
Anonymous
4 years ago
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 ) )
up
-2
shad at shartley dot net
3 years ago
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.
up
-6
shad at shartley dot net
3 years ago
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
To Top