Skip to content

Instantly share code, notes, and snippets.

@hjpbarcelos
Last active December 17, 2015 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hjpbarcelos/5605004 to your computer and use it in GitHub Desktop.
Save hjpbarcelos/5605004 to your computer and use it in GitHub Desktop.
<?php
/**
* Retorna o parâmetro POST se a chave $key existe em $_POST.
* Caso não esteja, o valor $default será retornado.
* Se nenhum valor $default for informado, retorna null.
*
* @return string|null
*/
function getPost($key, $defalt = null) {
if (isset($_POST[$key]) && !empty(isset($_POST[$key]))) {
return $_POST[$key] ;
}
return $default === null ? null : (string) $default;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment