我正在定制一个开源的phreebooks。我想更改模块名称。我成功地更改了phreebooks和phreedom的模块名称,但是当我更改phreedom的名称时,我无法打印任何pdf。我收到此错误
User: 1 Company: phree RUN-TIME WARNING: 'Creating default object from empty value' line 50 in file
F:\wamp\www\phree\modules\report\pages\popup_gen\pre_process.php
第50行,代码就像这样
if (isset($_GET['xfld'])) $report->xfilterlist[0]->fieldname = $_GET['xfld'];
有人可以告诉我我在哪里做错了。我过去3天一直在打它。
EDITED
if (isset($_GET['xfld'])) { // check for extra filters
if (!isset($_GET['xfld'])) $xfld = new stdClass();
echo "BLANK";
if (isset($_GET['xfld'])) $report->xfilterlist[0]->fieldname = $_GET['xfld'];
if (isset($_GET['xcr'])) $report->xfilterlist[0]->default = $_GET['xcr'];
if (isset($_GET['xmin'])) $report->xfilterlist[0]->min_val = $_GET['xmin'];
if (isset($_GET['xmax'])) $report->xfilterlist[0]->max_val = $_GET['xmax'];
}
isset($_GET['xfld']
是从URL设置的。
答案 0 :(得分:0)
$_GET['xfld'] = $xfld;
$xfld = NULL;
$xfld->success = false; // Warning: Creating default object from empty value
如果$ xfld已初始化为某个值但不是对象,PHP将报告不同的错误消息:
$xfld = something;
$xfld->success = false; // Warning: Attempt to assign property of non-object
您应该检查对象是否已存在:
if (!isset($_GET['xfld'])) $xfld = new stdClass();
否则,此代码不是"旧PHP"的等效替代品。隐式对象创建。