Skip to content

Commit

Permalink
MDL-9506 Added a function that checks an object for the definition of…
Browse files Browse the repository at this point in the history
… a given variable. Similar to in_array().
  • Loading branch information
nicolasconnault committed Apr 27, 2007
1 parent 8a31e65 commit 1f3f362
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/moodlelib.php
Expand Up @@ -7067,5 +7067,19 @@ function is_newnav($navigation) {
}
}

/**
* Checks whether the given variable name is defined as a variable within the given object.
* @note This will NOT work with stdClass objects, which have no class variables.
* @param string $var The variable name
* @param object $object The object to check
* @return boolean
*/
function in_object_vars($var, $object)
{
$class_vars = get_class_vars(get_class($object));
$class_vars = array_keys($class_vars);
return in_array($var, $class_vars);
}

// vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
?>

0 comments on commit 1f3f362

Please sign in to comment.