Added assert_var_set() - part of trying to deprecate required_variable (which

is used in two different ways)
This commit is contained in:
thepurpleblob
2005-06-07 12:35:39 +00:00
parent b20337b888
commit f24e18ee85
+13 -1
View File
@@ -351,6 +351,19 @@ function confirm_sesskey($sesskey=NULL) {
}
/**
* Improved ensure a variable is set
* Issue a (custom) error message if not
* @param mixed $var the variable
* @param string $error optional additional error message
*/
function assert_var_set( $var, $error='' ) {
if (! isset($var)) {
error( "a required variable is not set - $error" );
}
}
/**
* Ensure that a variable is set
*
@@ -371,7 +384,6 @@ function require_variable($var) {
* Ensure that a variable is set
*
* If $var is undefined set it (by reference), otherwise return $var.
* This function will soon be made obsolete by {@link optional_param()}
*
* @param mixed $var the variable which may be unset
* @param mixed $default the value to return if $var is unset