【发布时间】:2014-02-06 18:25:36
【问题描述】:
我有这个函数来填充我的类变量。当有文件要处理时,会调用handle_uploaded_files(),返回一个逗号分隔的文件列表名。
当我访问 $this->image 时,值是正确的 ("image(1).jpg,image(2).jpg,image(3).jpg,image(4).jpg"),但是当访问类外的属性时,我收到一个奇怪的结果:只有逗号,但在此之间没有值 (",,,")。
public function fill_vars($array, $files = null) {
foreach(array_keys($array) as $key => $value) {
$this->$value = $array[$value];
if (!empty($files)) {
foreach ($files as $key => $value) {
$this->$key = handle_uploaded_files($files[$key]);
}
}
}
}
我不知道发生了什么。有什么建议吗?
对不起,我的英语不好。
【问题讨论】:
标签: php string class properties