TNET Weather Project Page > PHP 5.3 Deprecated Warnings
PHP 5.3 Deprecated Warnings
PHP 5.3 Some sites are upgrading to PHP 5.3. This can cause issues with some scripts that use what are now considered Deprecated functions. The functions still work in PHP 5.3, but the default is to display a warning about those depreciated functions if they are found.
Turning off Depreciation Warnings
You can turn Off the warnings by finding the error_reporting and change it to below in your php.ini file:
error_reporting = E_ALL ^ E_DEPRECATED
Or by adding the following line in a script which is having this issue:
error_reporting(E_ALL ^ E_DEPRECATED);
Replacing split with preg_split
One of the common deprecated functions is the split() function. If split is being used with regex, you cannot replace it with explode() but must use preg_split() instead. explode() does not work with regex.
The format of split() and preg_split are almost exactly the same but with preg_split() you need to add delimiters (/.../)to contain the pattern where with split() you didn't.
Example... replacing split() with preg_split():$foundline = split("[\r\t ]+", $gotdat );
$foundline = preg_split("/[\r\t ]+/", $gotdat );
$foundline = preg_split("/[\r\t ]+/", $gotdat );
Replace split with explode
Not using regex in split(), means you can use the faster explode() function instead.
Example:list($lbl, $dat) = split("=", $value);
list($lbl, $dat) = explode("=", $value);
list($lbl, $dat) = explode("=", $value);
Limits in both functions are the same.
list($lbl, $dat) = split('=', $value,2);
list($lbl, $dat) = explode('=', $value,2);
list($lbl, $dat) = explode('=', $value,2);


