- trim: documentation ( source)
<?php
function contextCheck( $context = false ) {
# URL Paremeter Checker
# If the infomation passed is a string and isn't empty, grab URL paremeter
if( trim( $context ) !== false and is_string( $context )) {
# Check if the URL Parameter even exists
if ( isset( $_GET["{$context}"] ) ) {
$URL_Parameter = $_GET["{$context}"];
# If the URL Parameter is a string and isn't empty, return true
if( !empty( $URL_Parameter ) and is_string( $URL_Parameter ) ) {
return $URL_Parameter;
}
}
} else {
return false;
}
}
$_GET['foo'] = '12';
$_GET['bar'] = '0';
print( contextCheck( 'foo' ) );
print( contextCheck( 'bar' ) ); # This doesn't output :[
?>