php enable error prompt

(*-*)浩
Release: 2023-02-24 18:22:01
Original
3983 people have browsed it

php enable error prompt

The first method: Change the values ​​of display_errors and error_reporting in the php.ini file. If not, add directly (recommended learning: PHP Programming From entry to proficiency)

; 第一处修改
; display_errors = Off
display_errors = On

; 第二处修改
; error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
error_reporting = E_ALL | E_STRICT
Copy after login

display_errors

Error echo is commonly used in development mode, but many applications forget to turn off this in the formal environment. options. Error echo can expose a lot of sensitive information, which facilitates the attacker's next attack. It is recommended to turn this option off.

display_errors = On

When in the on state, if an error occurs, an error will be reported and an error message will appear

dispaly_errors = Off

In the closed state, if an error occurs, it will prompt: Server error. But no error message will appear

The parameters that error_reporting can set are as follows:

Error reporting is a bit field. You can add up the numbers to get the desired level of error reporting.

E_ALL – All errors and warnings (excluding E_STRICT)

E_ERROR – Fatal runtime errors

E_WARNING – Runtime warnings (non-fatal errors)

E_PARSE – Compile-time parsing error

E_NOTICE – Run-time reminder (These are often caused by bugs in your code, or may be caused by intentional behavior.)

E_STRICT – Encoding standardization warning, allowing PHP to recommend how to modify the code to ensure optimal interoperability and forward compatibility.

E_CORE_ERROR - Fatal error during PHP startup initialization

E_CORE_WARNING - Warning (non-fatal error) during PHP startup initialization

E_COMPILE_ERROR - Fatal at compile time Sexual error

E_COMPILE_WARNING – compile-time warning (non-fatal error)

E_USER_ERROR – user-defined error message

E_USER_WARNING – user-defined warning message

E_USER_NOTICE – User-defined reminder message

Second method: Add the following two sentences in Apache’s httpd.conf file

php_flag display_errors on
php_value error_reporting 2039
Copy after login

The above is the detailed content of php enable error prompt. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!