我正在使用一个插件在opencart中获得支付。但是我认为PHP代码中有一些错误。
示例:PHP警告:为foreach()提供的参数无效
<?php
***************************
***************************
***************************
private $category_installment = array();
private $category_full;
public function __construct()
{
$this->hash = new Hash();
}
***************************
***************************
***************************
protected function categorySearch($category_id = 0)
{
if (!empty($this->category_full[$category_id]) and array_key_exists($this->category_full[$category_id], $this->category_installment)) {
$return = $this->category_installment[$this->category_full[$category_id]];
} else {
foreach ($this->category_full as $id => $parent) {
if ($category_id == $id) {
if ($parent == 0) {
$return = 0;
} elseif (array_key_exists($parent, $this->category_installment)) {
$return = $this->category_installment[$parent];
} else {
$return = $this->categorySearch($parent);
}
} else {
$return = 0;
}
}
}
return $return;
}
}
你能帮我找到代码中的错误吗?(Opencart扩展)
1条答案
按热度按时间k3bvogb11#
循环前检查数据类型,使用:获取类型();