All php errors should be written to a log file and examined regularly. If you do not do this - there is a chance to miss some bugs that appear in the process of work or testing and do not appear on the screen

Enabling log files with .htaccess:

php_value display_errors on  
php_value display_startup_errors on  

Enabling log files with .htaccess, advanced version:

php_flag ignore_repeated_errors off  
php_flag ignore_repeated_source off  
php_flag track_errors on  
php_flag display_errors on  
php_flag display_startup_errors on  
php_flag log_errors on  
php_flag mysql.trace_mode on  
php_value error_reporting -1  
php_value error_log /path/to/site/php-errors.log  

The php errors will be displayed and also logged in the php-errors.log file

Output the errors from the php script:

ini_set("display_errors", "1");  
`` ini_set("display_startup_errors", "1");
ini_set('error_reporting', E_ALL);  

Enabling logfiles by changing php.ini:

error_reporting = E_ALL  
display_errors = On  
display_startup_errors = On  
log_errors = On  
log_errors_max_len = 1024  
error_log = home/username/folder  

Errors on manual start or when running the script through the cron do not go into the log. You can display the result of the script in a separate file by adding at the end of the command: &>> /home/user name/logs/cron.log. You can specify any path to the log file within your home directory

The full command will look like this:

/usr/local/bin/php /home/username/public_html/xml/script.php &>> /home/username/logs/cron.log
Updated Oct. 26, 2024