No error appears in PHP

Asked

Viewed 231 times

0

I am making a very simple code in PHP and inserting an error on purpose, when I update my browser the result that appears to me is just a blank page, I would like an error to appear with the cause and the line of error.

Obs: use Ubuntu 18.04

1 answer

0


Place these two lines at the beginning of your code that will make PHP report and show ALL the errors and warnings:

ini_set('error_reporting', E_ALL); // mesmo resultado de: error_reporting(E_ALL);
ini_set('display_errors', 1);

If you want your entire environment to display such errors and warnings, change these same directives in the PHP configuration (file php.ini) and restart the HTTP server (Apache/IIS/Nginx/etc).

Example of configuration of error_reporting:

Print php.ini

Obs.: lines started by semicolon ; are comments. Configuration is by line:

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

Options are available in the documentation.

More details, see documentation:

PHP: error_reporting

PHP: display_errors

PHP: ini_set

  • The display error only the Production Value variable is 'off' and in error_reporting the variables have the following values: ; error_reporting ; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED ; Development Value: E_ALL ; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT

  • @zeka04 I need to tell you that the lines started by ; are just comments or you already know? kk

  • so all this is comment and not config from my php? sorry I’m beginner

  • @zeka04 updated response, bro

  • I guess now it will, so I just need to change this line that you indicted by error_reporting = E_ALL? Because she already has the value that is in your print

  • @zeka04 then, man. Ideally you set up as YOUR need. E_ALL reports everything. But you still need to check the directive display_errors. Otherwise errors will not be displayed in the browser. Only in logs.

  • I changed the display_errors directive to ON and it still doesn’t work... damn that crazy

  • @zeka04 Restarted Apache/Nginx server?

  • 1

    Damn it, thank you so much for your patience and attention.

Show 4 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.