How can PHP controllers differentiate between regular requests and Ajax requests to return appropriate responses?

PHP controllers can differentiate between regular requests and Ajax requests by checking the `HTTP_X_REQUESTED_WITH` header. Regular requests typically do not have this header, while Ajax requests sent using frameworks like jQuery will include it with a value of `XMLHttpRequest`. By checking for this header, controllers can return appropriate responses for each type of request.

if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
    // This is an Ajax request
    // Return appropriate response
} else {
    // This is a regular request
    // Return appropriate response
}