Skip to content

Instantly share code, notes, and snippets.

@bencooling
Created September 16, 2013 23:10
Show Gist options
  • Save bencooling/6587902 to your computer and use it in GitHub Desktop.
Save bencooling/6587902 to your computer and use it in GitHub Desktop.
PHP: Snippets
<?php
// Conditional Ajax vs regular HTTP response
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
echo json_encode($arr);
exit;
}
else {
// do something
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment