Solve problems such as PHP display warning and notice

Source: Internet
Author: User

PHP after installation, will be in the php.ini file set errors, reminders, warnings and other ways to appear, so that we can debug PHP program in time to understand the problem of the program. Then, sometimes we do not need reminders, warnings and other content, such as when we use PHP5.5 (or higher), with the MySQL development environment, using the older MySQL connection mode, PHP will prompt: Please use the latest MySQL connection mode, When you use its read database content as JSON format (or other) to return to the foreground, there is often an error in the content

How to block this error, the method has the following:

1. Add a masking Error alert on a page that may (or has been) a reminder, or error, or warning:

Error_reporting (e_all ^ e_deprecated);

In this version of php5.5, old-fashioned MySQL connection methods are not recommended

But speedphp still follow the old-fashioned connection method, then PHP will report e_deprecated hint, at this time to turn off the prompt is OK, you can also

PHP is placed in deployment mode (non-development mode), but the best solution is to use the latest speedphp

General can also use the following content to solve some notice waring and other issues

Ini_set ("Display_errors", 0);

Error_reporting (e_all ^ e_notice);

Error_reporting (e_all ^ e_warning);

2, open the php.ini file, find the relevant settings (such as), change on to OFF, you can mask the error (this method is not recommended):

Sometimes modify the php.ini dispaly_errors or not, then refer to the following method:

Modify PHP.ini, change display_errors = on to Display_errors = OFF, the result is still not working. Baidu, the original also in the php-fpm.conf set.

Open php-fpm.conf, find:

<value name= "Php_defines" >

</value><value name= "Sendmail_path" >/usr/sbin/sendmail-t-i</value>

<value name= "Display_errors" >0</value>

Change the value from 1 to 0.

3, this method is very suitable for those projects have decided to adopt some kind of certain will cause a reminder or warning way, one trick shielding, once and for all:

First refer to 2, find the relevant dispaly_errors position, change Off to On

Then find this location, modify the level you need to error, or do not need to error the level

The following error levels are referenced:

If the parameter level is not specified, the current error levels are returned. The following items are possible values for level:

1 E_error
2 e_warning
4 E_parse
8 E_notice
E_core_error
E_core_warning
E_compile_error
E_compile_warning
E_user_error
E_user_warning
1024x768 E_user_notice
2047 E_all
2048 e_strict
E_notice indicates that the general situation is not recorded and is only used if the program has an error condition, such as attempting to access a nonexistent variable, or calling stat () to view files that do not exist.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.