我的 php 教程之一是显示波纹管功能。我知道它用于检查属性是否存在,但我无法理解它的真正含义,我的意思是它的注释行的含义是什么?谁能给我解释一下?
private function has_attribute($attribute) {
//get_object_vars returns an associative array with all attributes
//(incl.private ones!) as the keys and their current values as the value
$object_vars = get_object_vars($this);
//we don't care about the value, we just want to know if the key exists
//will return true or false
return array_key_exists($attribute, $object_vars);
}