1

I am getting the below message on my sites page there are more than 20 messages like this... pls guide me to rectify the issue... I am using the PHP 5.3.0

Deprecated: Function eregi() is deprecated in C:\wamp\www\bannerbuzz\includes\classes\language.php on line 87

> UPDATE : Is there any way to switch off this display of error?

OM The Eternity
  • 15,694
  • 44
  • 120
  • 182

5 Answers5

3

The correct answer to your question is: use a different error setting on your site. You can do that in one of 3 ways.

Change the php.ini file, if you have the right to.

error_reporting  =  E_ERROR
display_errors = Off

Add an .htaccess file to the root directory of your site You also have to have the right to do this. Add the following lines:

php_flag display_errors off
php_value error_reporting E_ERROR

Execute the following statements in the beginning of your script

error_reporting(E_ERROR);
ini_set("display_errors","Off");

However, in concurrence with the other answers given, the errors you get are errors and you should resolve them. Most of the time you want to show errors in your development environment and suppress and log them in your production environment. But you always want to solve them.

Check out the PHP manual for more info on errors.

Niels Bom
  • 8,728
  • 11
  • 46
  • 62
2

Perhaps because the function is deprecated? You can always change the error_reporting settings, but it's better that you stop using deprecated functions!

From PHP.net:

This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.

I believe it is also removed as of PHP 6. Why not just use preg_match?

animuson
  • 53,861
  • 28
  • 137
  • 147
2

In PHP 5.3, there are certain things that are deprecated, that is no more supported, however, there exists an alternative for them in php 5.3 for you to use.

See complete list of:

Deprecated features in PHP 5.3.x

Note: The ereg is removed, you can use preg family of functions instead.

Sarfraz
  • 377,238
  • 77
  • 533
  • 578
  • 2
    @OM The Eternity: You should not switch of the display of errors if you want to see what functions are depracated otherwise your site might not give the expected results and calculations. Howerver try this but i am not sure whether it will work with deprecated functions errors. `ini_set('display_errors', false);` – Sarfraz May 24 '10 at 07:26
  • Ok I guess its better to change the functions isnt it? – OM The Eternity May 24 '10 at 07:32
  • @OM The Eternity: That is the way to go :) – Sarfraz May 24 '10 at 07:37
  • 1
    @Sarfraz: As of 5.3 E_DEPRECATED is it's own trigger that turning off error reporting would hide but I shudder at the approach – Dan Heberden May 24 '10 at 08:00
  • @Dan Heberden: That is useful and rightly said in terms of not hiding it :) – Sarfraz May 24 '10 at 08:08
1

In my case, I'm using a third party library which makes use of the eregi function. In that case, there's an easy solution to hide those warnings. Just place ob_start() and ob_end_clean() at the beginning and the end of the code:

ob_start();
// third party code
// and more code ...
if (eregi("blah", $var)) {  // <-- this code is throwing a warning
    // ..
}
// and more code ...
ob_end_clean();

And that's all.

Gonzalo
  • 11
  • 1
0

Try preg_match or preg_replace, functions that aren't depreciated :)

For changing the error level:

http://php.net/manual/en/function.error-reporting.php

Dan Heberden
  • 10,990
  • 3
  • 33
  • 29