How to display errors in PHP?

Executing a PHP file can result in an error and there are cases when you don't get any information about the things that went wrong in the process as you could see a blank page or any weird things on the browser. This page explains how to display errors in PHP.

How to display errors in PHP?

These errors are logged in the PHP log file or the server log file, but you can simply make changes to your code to quickly view it on the browser.

PHP Error Log file location in Nginx

PHP error log file location is same as Nginx error log. The Nginx error log and access log file is located at -


To open the file using less command, you can use the +G option to check the latest entries made in the file -

$ less +G /var/log/nginx/error.log

or simply view the last 100 lines using tails command -

tail /var/log/nginx/error.log -n 100


Reload parent page after AJAX modal popup is closed.

Modal popup window is more elegant way of showing information to the user in views,webform, etc. We can also insert an ajax modal popup link for a webform in a global text field of a view. When the view is rendered, the link is displayed to display the webform in an ajax dialog box, but many a times, when the webform is filled with newer values and saved on the ajax itself, the parent page, in this case, the view, is not refreshed to show the updated values in the form.

Set default value for datepicker using jQuery in Drupal

Datepicker in drupal is rendered as separate select elements for day, month and year by default which makes it difficult to set a default value if we want to set it to some string value, eg. today, +2 months, etc. This page is to check how we can set default value for datepicker using a simple jQuery.

Get string from PHP

Consider you have the above string value. If you are sending this value from a php code, convert it to a date format using strtotime().