Although most web servers have an inbuilt error log system these access and error logs do not always provide sufficient information on the source of specific PHP errors.
PHP on itself however has an inbuilt error report/handling option.
Here is how to activate this feature in four steps:
01: Edit File php.ini:
sudo nano /etc/php7/apache2/php.ini
set values corresponding to these (line numbers may be different!):
445: error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
462: display_errors = On
483: log_errors = On
571: error_log = /var/log/php-errors.log
02: Now create the log-file:
sudo touch /var/log/php-errors.log
03: Change ownership to make the file accessible to the Apache user:
sudo chown wwwrun /var/log/php-errors.log
04: Restart Apache:
sudo service apache2 restart
or
sudo systemctl restart apache2
As of now any php-errors will be logged in this file!