Created
January 23, 2016 06:19
-
-
Save ahungry/a60d47e1d5802ae91737 to your computer and use it in GitHub Desktop.
Safely get post data or defaults
This file contains hidden or 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 post($key, $default = '') | |
{ | |
return isset($_POST[$key]) ? $_POST[$key] : $default; | |
} | |
$name = post('name', 'Jon Smith'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With magical class: