“array (
'workflowid' => '',
'ishtml' => '0',
'content_ishtml' => '0',
'create_to_html_root' => '0',
'template_list' => 'jiping',
'category_template' => 'category',
'list_template' => 'list',
'show_template' => 'show',
'meta_title' => '',
'meta_keywords' => '',
'meta_description' => '',
'presentpoint' => '1',
'defaultchargepoint' => '0',
'paytype' => '0',
'repeatchargedays' => '1',
'category_ruleid' => '30',
'show_ruleid' => '32',
)”然后读取时候,用函数string2array()转换为数组,函数是:/**
* 将字符串转换为数组
*
* @param string $data 字符串
* @return array 返回数组格式,如果,data为空,则返回空数组
*/
function string2array($data) {//MIAO
if($data == '') return array();
@eval("\$array = $data;");
return $array;
}其中eval()用了屏蔽符@,但还是会报错,报错内容是:(
syntax error, unexpected ',' E:\web\zcms\admin\Common\common.php(187) : eval()'d code 第 8 行.
错误位置
FILE: E:\web\zcms\Core\Lib\Core\Think.class.php LINE: 275
但因为这个转换是所有的栏目用foreach遍历的时候报错,但我想知道到底是哪个栏目的setting在报错,
然后我用try{ }catch(ThinkphpException){ }也还是报原生的错,代码是:
foreach($this->categorys as $r) {
try{
$setting = string2array($r['setting']);
}catch(ThinkException $e){
var_dump($r['setting']);
}
}没走到我自定义的捕获错误这一步,我再把调试模式关掉,原生错误没有了,但还是没走到捕获错误这一步。请解答为什么,或者有什么其他的方法可以确定到底是哪个栏目的setting在报错,我还得说明:我看了数据表中的setting字段都是没问题的。 最佳答案