WordPress displays a default error message when it encounters a PHP error-
There has been a critical error on this website.
Learn more about troubleshooting WordPress.
Now this message is subtle, but still reveals 2 things-
- Your website has some error
- Your website is built on WordPress
Now second point is usually fine unless you specifically do not want WordPress name to appear anywhere on your website.
But the first point can become a security issue. Luckily there is a way to modify it.
This message is handled by WP_Fatal_Error_Handler class in wp-includes folder. Out of many methods, they give option of a drop-in file which can override the default php error message.
Just create a file with the name “php-error.php” and put it in the wp-content folder. Write the html code for PHP error message.
Now whenever WordPress will encounter a php error, it will execute this file and will display whatever you wrote in that file.