Last active
December 17, 2015 03:49
-
-
Save picasso250/5546457 to your computer and use it in GitHub Desktop.
sugar functions in php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function _get($key = null, $or = null) | |
{ | |
if ($key === null) | |
return $_GET; | |
return isset($_GET[$key]) ? trim($_GET[$key]) : $or; | |
} | |
function _post($key = null, $or = null) | |
{ | |
if ($key === null) | |
return $_POST; | |
return isset($_POST[$key]) ? ($_POST[$key]) : $or; | |
} | |
function _req($key = null, $or = null) | |
{ | |
if ($key === null) | |
return $_REQUEST; | |
return isset($_REQUEST[$key]) ? ($_REQUEST[$key]) : $or; | |
} | |
function is_post() { | |
return $_SERVER['REQUEST_METHOD'] === 'POST'; | |
} | |
function is_ajax() { | |
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment