开发者

I get a "Deprecated" notice on my page with few of the session functions

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?


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.


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.


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?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜