Deprecated: Function … is deprecated in PHP

Symptom:

Shows errors like below on your Joomla, Drupal or in any other php coded webpage.

  • Deprecated: Function ereg() is deprecated in …
  • Deprecated: Function split() is deprecated in …
  • Deprecated: Function set_magic_quotes_runtime() in …
  • …will add more…Please let me know if you find more.

Reason:

Those functions got replaced with alternate ones. (Sorry that I don’t know the reason behind that. May be the new ones might have some new features). Also I experienced this problem after upgrading PHP engine on my server.

Fix:

ereg() fix:

FTP the web server and open the file showing error, search for “ereg” and replace ereg(…) with mb_ereg(…). The syntax is same for both. (Try this and keep it if it works. It will work 90% sure.)

split() fix:

FTP the web server and open the file showing error, search for “split” and replace split(…) with explode(…). (Same as above.)

set_magic_quotes_runtime() fix:

Replace the below line showing error

set_magic_quotes_runtime(0);

with below code

// Check if magic_quotes_runtime is active
if(get_magic_quotes_runtime())
{
// Deactivate
set_magic_quotes_runtime(false);
}

Note: More findings will be added to this post as and when I experience them. Please comment below if you had experienced and fixed any other deprecations.