What is the trigger trigger function in PHP?

Can I use the trigger_error function when the site is live?

An example is below.

// Make the connection: $dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if (!$dbc) { trigger_error ('Could not connect to MySQL: ' . mysqli_connect_error() ); } 
+6
source share
1 answer

While you are not displaying errors on screen ( display_errors = Off ) in php.ini, it is advisable to use trigger_error() in the script. This will cause the error message to be written to the error log.

I will add that it is generally not recommended to use @ to suppress errors. Problems with mysqli_connect() will also be written to the error log if you leave @ .

+5
source

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


All Articles