Quick fix for the ‘Deprecated: Function eregi() is deprecated ‘ issue / error with phpThumb and PHP 5.3+

I recently upgraded a production server to PHP 5.3.6 from a much earlier 5.2.x build and noticed that the process had killed all instances of phpThumb on the server due to the deprecation of the functions ‘eregi’, ‘ereg’, ‘split’ & ‘eregi_replace’.

See:- http://php.net/manual/en/migration53.deprecated.php for a full list of functions deprecated since PHP 5.3.0.

The messages being output by phpThumb are similar to:

Deprecated: Function eregi() is deprecated in /home/test/public_html/phpThumb/phpThumb.php on line 152

The quickest fix is to modify phpThumb.php to suppress the warnings, open the file and change the first few lines from:

error_reporting(E_ALL);
ini_set('display_errors', '1');

To

error_reporting(0);
 ini_set('display_errors', '0');

This will SUPPRESS ALL PHP WARNINGS & ERRORS from phpThumb, so if you get other errors you won’t know much about it.
A BETTER way to remove the errors is to patch phpThumb, all calls to the deprecated functions need replacing.

As an interim measure, until an updated version of phpThumb is released, I have patched a copy of phpThumb 1.7.9 to be PHP 5.3.0+ compatible.

Download the patched version of phpThumb 1.7.9 that has been fixed to work with PHP 5.3.x

If anyone finds an bugs let me know and I’ll patch them.

You can now use this patched version https://github.com/simpson/phpThumb-for-PHP-5.3, thanks Tantuss.



7 thoughts on “Quick fix for the ‘Deprecated: Function eregi() is deprecated ‘ issue / error with phpThumb and PHP 5.3+”

  1. gosunkugi says:

    till now, august 2012, is any bug there? anyway I will use it immediately, and thank a lot for the fixing 😀

  2. gosunkugi says:

    till now, august 2012, is any bug there? anyway I will use it immediately, and thank a lot for the fixing 😀

  3. S3nd41 says:

    I applied your fix and I keep getting the ereg error and now I get even an additional error:
    [13-Nov-2012 12:22:24 UTC] PHP Notice:  Undefined offset: 0
    Is there some way to solve this?

  4. coduanh says:

    This fix work for me completely. I spend a lot of time to fix until I find this article. Thanks a lot

  5. bhupen says:

    It dosen’t fix my problem at all i got the following error after replacing your folder:
    http://www.photoloveletter.co.uk/includes/thumb/phpThumb.php?zc=1&q=100&w=1098&h=1088&fltr%5B%5D=crop|0|0|41.84|146.44&fltr[]=bord|9|0|0|ffffff&src=/images/flash/userimages/1353443087_2.jpg

  6. Sonny says:

    Got this error: Warning: preg_match() [function.preg-match]: No ending delimiter ‘^’ found in …/phpThumb/phpthumb.class.php on line 1024

Leave a Reply

Your email address will not be published. Required fields are marked *