Return to Snippet

Revision: 17278
at August 30, 2009 14:01 by mondomondomxcom


Initial Code
function getVar($str, $default="") {
  return (isset($_POST[$str]) ? $_POST[$str] : (isset($_GET[$str]) ? $_GET[$str] : $default));
}

Initial URL

                                

Initial Description
This is just a simple function to get the variable without having to worry if its POST or GET, and even allows for a default value to be passed in case the variable was not found.

Initial Title
PHP Get Variable

Initial Tags
php, post

Initial Language
PHP