PHP Error Setting on Local and Remote Apache Servers

Question: With Apache/PHP, can I use php_admin_* flags and ini_set() in conjunction to show PHP errors locally and hide them remotely without any changes to the remote configuration? The idea is to turn show error flags on in the local httpd.conf file, and off in both the local and remote index file. This is useful where there is no access to httpd.conf or php.ini files remotely.

Local httpd.conf file - turn on error display:

php_admin_flag display_startup_errors on
php_admin_value display_errors on
php_admin_flag error_reporting on
php_admin_value error_reporting 2147483647

index.php file (duplicated in local and remote servers) - leave error display on due to above, but turn it off remotely:

ini_set('error_reporting', 0);
ini_set('display_errors', 'Off');
ini_set('display_startup_errors', 'Off');

Note: according to the docs ini_set should take all strings, but 0 is recommended for error_reporting.

Theory: This allows "fire and forget" proper error display without having to routinely change files or maintain configurations between local and remote servers.

1) The php_admin_* settings in the httpd.conf (or vhost) file on the local server will override any settings in the php.ini, .htaccess, and especially the eg index.php code file to enable error display on in the local development machine; and

2) the settings in the index.php file, when deployed, will override the normal (non-php_admin_*) settings in php.ini on the deployment / production server to disable error display to the user on the remote production server. This is good if the production machine is or becomes misconfigured to display possibly confidential error information to the user.

I can't find exactly this approach talked about anywhere, but it EDIT: does -not- seem to work on my setup with a local (currently homebrew with Apache 2.4 and PHP 7.1 - php7_module) server on a mac, and a remote (Linux) host on the web.

Am I missing or misunderstanding something with this approach?

Some references;

How to get useful error messages in PHP? "...you can forget to turn error reporting for production site..."

php_admin_flag: php_admin_flag values: http://php.net/manual/en/install.fpm.configuration.php

php.net "How to change configuration settings" http://php.net/manual/en/configuration.changes.php

php.net "Runtime Configuration" http://php.net/manual/en/apache.configuration.php

php.net "ini_set()" http://php.net/manual/en/function.ini-set.php

php.net "Configuration" http://php.net/manual/en/install.fpm.configuration.php

链接地址: http://www.djcxy.com/p/58934.html

上一篇: 如果$ a和$ b在数组中,那么$ a + $ b的结果是什么?

下一篇: 在本地和远程Apache服务器上设置PHP错误