[英]PHPTAL -Trying to get property of non-object while using macros
I am using PHPTAL 1.2.2 Template page is template.tpl 我正在使用PHPTAL 1.2.2模板页面是template.tpl
<form>
<div tal:repeat="field fields">
<tal:block tal:define="name repeat/field/key" metal:use-macro="${field/type}" />
</div>
</form>
<tal:block metal:define-macro="text">
<label>${field/label}</label><input name="${name}" type="text" value="${field/value}" />
</tal:block>
<tal:block metal:define-macro="select">
<label>${field/label}</label><select name="${name}">
<tal:block tal:repeat="value field/valuelist">
<option tal:condition="php:field.value != value" value="${value}">${value}</option>
</tal:block>
</select>
</tal:block>
And my php page is 而我的PHP页面是
<?php
require_once 'PHPTAL.php';
$fields = array(
'name' => array('label'=>'Name','type'=>'text','value'=>'Test User'),
'user' => array('label'=>'Age','type'=>'select','valuelist'=>array(1,2,3),'value'=>2) ,
);
$t = new PHPTAL('tempalte.tpl');
$t->fields = $fields;
try {
echo $t->execute();
}
catch (Exception $e){
echo $e;
}
?>
I was getting an error in ie as "Trying to get property of non-object in C:\\Windows\\Temp\\tpl_4d6be820_formonline1__HAfMCyjTSQl6RgUTRjXcHA.php on line 24" 我在“正在尝试在第24行上获取C:\\ Windows \\ Temp \\ tpl_4d6be820_formonline1__HAfMCyjTSQl6RgUTRjXcHA.php中非对象的属性”的错误中
But in firefox and chrome it works fine but i view source there was lot of html code in it other than that tag. 但是在firefox和chrome中,它可以正常工作,但是我查看源代码,除了那个标记外,还有很多html代码。
This also happened to me when I concatenated a string to my echo statement. 当我将字符串连接到echo语句时,这也发生在我身上。 The variable is assigned.
变量已分配。
if($des != NULL)
echo '<p><a href="javascript:rightgroupnav()">'.$des->name.'</a></p>';
This line works in Chrome and Firefox. 该行适用于Chrome和Firefox。 But not Internet Explorer.
但不是Internet Explorer。 I tried also to teste it in this way
我也尝试用这种方式来证明
<p><?=$des->name?></p>
This works, and I hope you can find it helpful. 这行得通,希望对您有所帮助。 Does anyone know why they seem to parse data differently?
有谁知道为什么他们似乎以不同的方式解析数据?
Such PHP errors only happen inside php:
prefixed expression, so it's probably about php:field.value
. 此类PHP错误仅在
php:
前缀表达式内发生,因此可能与php:field.value
。 See if field
is an object. 查看
field
是否为对象。 If it's an array, then you need php:field['value']
. 如果是数组,则需要
php:field['value']
。 If it can be NULL, then you need to check for that. 如果可以为NULL,则需要检查。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.