How to make PHP programmatic output all error information?

I cannot change php.ini for some reason,

How can I do this at the code level?

+4
source share
5 answers

Try

  • ini_set - Sets the value of a configuration parameter

Example from the manual:

 if (!ini_get('display_errors')) { ini_set('display_errors', 1); } 

but remember that your hosting service may have disabled the ini software settings.


Also keep in mind that you must enable error_reporting :

Example from the manual:

 // Report all PHP errors error_reporting(-1); 
+4
source

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

In particular,

 ini_set('display_errors', 'E_ALL'); 

must work

+1
source
 error_reporting(-1); //Passing in the value -1 will show every possible error, even when new levels and constants are added in future PHP versions ini_set('display_errors', 'On'); 

Doc Available:

Another way (if your server supports it) is with the .htaccess file:

 php_flag display_errors on php_value error_reporting -1 
0
source

Error reporting runtime configuration can be solved using a number of functions listed here: http://www.php.net/manual/en/errorfunc.configuration.php

But most directly related to your question, use error_reporting (E_ALL) and display_errors (1)

0
source

In PHP:

 error_reporting(E_ALL | E_STRICT); 

From the .htaccess file:

 php_value error_reporting 6143 

6143 is an integer value of E_ALL, since apache does not understand "E_ALL"

0
source

Source: https://habr.com/ru/post/1308796/


All Articles