Here is the tutorial of achieving the result.
Example:
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
{
exit;
}
continue;
This checks if the
HTTP_X_REQUESTED_WITH
parameter is not empty and if it’s equal toxmlhttprequest
, then it will exit from the script.