Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 数组作为类变量,在类的构造中设置_Php_Arrays_Oop - Fatal编程技术网

Php 数组作为类变量,在类的构造中设置

Php 数组作为类变量,在类的构造中设置,php,arrays,oop,Php,Arrays,Oop,是否有方法将数组传递给类/对象构造并访问/返回或操作它 代码: 替换 return $this->$affiliates; ^ |-------- Remove This 与 替换 return $this->$affiliates; ^ |-------- Remove This 与 我看不出真正的问题在这里。那代码不是已经做了你想要的吗?我看不出这里有什么真正的

是否有方法将数组传递给类/对象构造并访问/返回或操作它

代码:

替换

return $this->$affiliates;
              ^
              |-------- Remove This 

替换

return $this->$affiliates;
              ^
              |-------- Remove This 


我看不出真正的问题在这里。那代码不是已经做了你想要的吗?我看不出这里有什么真正的问题。那代码不是已经做了你想要的吗?
return $this->affiliates;
   public function getAffiliatesArray() {
            return $this->$affiliates;
        }

   should be

  public function getAffiliatesArray() {
        return $this->affiliates;
    }