Return to Snippet

Revision: 6523
at May 27, 2008 13:11 by luizlopes


Initial Code
/* Get a variable from the possible input sources. */
function getVar($var_name) {
    if (!empty($_GET[ $var_name ])) {
        return $_GET[ $var_name ];
    } elseif (!empty($_POST[ $var_name ])) {
        return $_POST[$var_name ];
    } elseif (!empty($_SESSION[ $var_name ])) {
        return $_SESSION[ $var_name ];
    } elseif (!empty($_COOKIE[ $var_name ])) {
        return $_COOKIE[ $var_name ];
    } else {
        return null;
    }
}

Initial URL

                                

Initial Description
This can be used as a general function to get the value stored in any of the possible input sources. 
use

Initial Title
General get value from possible input sources

Initial Tags
post

Initial Language
PHP