Home Backend Development PHP Problem How to close php error in htaccess

How to close php error in htaccess

Jul 10, 2021 am 10:22 AM
htaccess

htaccess method to turn off php errors: first find the ".htaccess" file; then put the "php_flag display_startup_errors off" and other codes into the ".htaccess" file in the corresponding directory.

How to close php error in htaccess

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

How to close php error in htaccess?

Use .htaccess to turn off PHP error display

Put the following corresponding code into the .htaccess file in the corresponding directory to achieve the corresponding function.

Turn off error display:

php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_value docref_root 0
php_value docref_ext 0
Copy after login

Only display PHP errors:

php_flag  display_errors        on
php_flag  display_startup_errors on
php_value error_reporting        2047
Copy after login

Among them, "2047" is the level of the error to be displayed. The detailed table is as follows:

1 E_ERROR
2 E_WARNING
4 E_PARSE
8 E_NOTICE
16 E_CORE_ERROR
32 E_CORE_WARNING
64 E_COMPILE_ERROR
128 E_COMPILE_WARNING
256 E_USER_ERROR
512 E_USER_WARNING
1024 E_USER_NOTICE
2047 E_ALL
2048 E_STRICT
4096 E_RECOVERABLE_ERROR
Copy after login

To save errors to a log file, you can set it like this:

# enable PHP error logging
php_flag  log_errors on
php_value error_log  /home/path/public_html/domain/PHP_errors.log
Copy after login

Then, you can set not to allow access to the .log file:

# prevent access to PHP error log
Order allow,deny
Deny from all
Satisfy All
Copy after login

Set the maximum size of the error log, in bytes Unit:

# general directive for setting max error size
log_errors_max_len integer
Copy after login

Based on the above, summary of PHP error display settings for .htaccess:

# PHP error handling for production servers
# disable display of startup errors
php_flag display_startup_errors off
# disable display of all other errors
php_flag display_errors off
# disable html markup of errors
php_flag html_errors off
# enable logging of errors
php_flag log_errors on
# disable ignoring of repeat errors
php_flag ignore_repeated_errors off
# disable ignoring of unique source errors
php_flag ignore_repeated_source off
# enable logging of php memory leaks
php_flag report_memleaks on
# preserve most recent error via php_errormsg
php_flag track_errors on
# disable formatting of error reference links
php_value docref_root 0
# disable formatting of error reference links
php_value docref_ext 0
# specify path to php error log
php_value error_log /home/path/public_html/domain/PHP_errors.log
# specify recording of all php errors
php_value error_reporting 999999999
# disable max error string length
php_value log_errors_max_len 0
# protect error log by preventing public access
Order allow,deny
Deny from all
Satisfy All
Copy after login

The following are settings suitable for developer applications:

# PHP error handling for development servers
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag log_errors on
php_flag ignore_repeated_errors off
php_flag ignore_repeated_source off
php_flag report_memleaks on
php_flag track_errors on
php_value docref_root 0
php_value docref_ext 0
php_value error_log /home/path/public_html/domain/PHP_errors.log
php_value error_reporting 999999999
php_value log_errors_max_len 0
Order allow,deny
Deny from all
Satisfy All
Copy after login

Recommended learning: " PHP video tutorial

The above is the detailed content of How to close php error in htaccess. For more information, please follow other related articles on the PHP Chinese website!

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 admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1658
14
PHP Tutorial
1257
29
C# Tutorial
1231
24