When PHP code fails, such as an undefined variable, a failed include or running out of memory, PHP writes a message to a log. Where it goes depends on configuration: the error_log setting can point to a file, and otherwise messages go to the web server's error log or to the system logger. On many hosts the path is something like /var/log/php_errors.log, but it varies.

The log is a useful source of evidence. Unusual errors on a public script, repeated memory exhaustion messages, or warnings that include odd input can show that someone is probing the application. It is also where you see why a request ended with a 500.

Two settings matter for safety. Errors should be logged and not displayed in production, so set display_errors off, because error text shown to visitors can reveal file paths and internals. The log should also be readable only by administrators, and it should be rotated so it does not fill the disk.

Know where your PHP logs are, and check them when you investigate a suspicious request.