]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9506 Added a function that checks an object for the definition of a given variabl...
authornicolasconnault <nicolasconnault>
Fri, 27 Apr 2007 03:54:53 +0000 (03:54 +0000)
committernicolasconnault <nicolasconnault>
Fri, 27 Apr 2007 03:54:53 +0000 (03:54 +0000)
lib/moodlelib.php

index 0a98799af593f10996985dd682647f38ee2e3851..72a5f09393ee9b90407829dd3033affe7519f19a 100644 (file)
@@ -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:
 ?>