references:joomla.framework:environment:jrequest-getvargetVar
Fetches and returns a given variable. The default behaviour is fetching variables depending on the current request method: GET and HEAD will result in returning an entry from $_GET, POST and PUT will result in returning an entry from $_POST. You can force the source by setting the $hash parameter:
Syntaxmixed getVar ( $name, $default, $hash, $type, $mask )
ExamplesExample 1Fetch the ‘id’ variable assigning the value 0 if it does not exist. Example 1 $id = JRequest::getVar( 'id', 0 ); Example 2Fetch the ‘name’ variable, assigning the value ‘none’ if it doesn’t exist. The variable will be retrieved from the $_POST variable and will be treated as a string. Unsafe HTML will be filtered out. Example 2 $name = JRequest::getVar( 'name', 'none', 'POST', 'STRING', JREQUEST_ALLOWHTML ); Example 3Options can be combined by logically ORing them as here where trimming is also suppressed. Example 3 $name = JRequest::getVar( 'name', 'none', 'POST', 'STRING', JREQUEST_ALLOWHTML | JREQUEST_NOTRIM ); |


