对于我的代码可能有什么问题,我已经没有想法了。这个特定的类接受一个数组,并根据另一个数组检查它以获得公共值。然后它通过 final_post_vars_keys() 函数提供对公共值的访问。但是每当我运行代码时,我都会收到错误(在标题中)。
<?php
class PostVarsKeys {
private $general_keys = array("name", "email", "custom phone" , "lastname" , "firstname", "fname", "lname", "phone" , "emailaddress" ,
"phonenumber");
private $post_vars_keys = array();
public function __construct($post_keys){
$counter=0;
foreach($post_keys as $key => $value):
$this->post_vars_keys[$counter++] = $key;
endforeach;
}
public function final_post_vars_keys(){
return $final_keys = array_intersect($this->general_keys, $this->post_vars_keys);
}
}