Added assert_var_set() - part of trying to deprecate required_variable (which
is used in two different ways)
This commit is contained in:
+13
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user