好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

Yii开发过程中的低级错误

忘写 echo

在下面的视图输出中:

<h1>Edit item: <?php $model->label; ?></h1>

你可能会花费很多时间去测试为什么 $model->label 没有值.

错误使用 echo

在下面的视图输出中:

<h1>Edit item: <?php echo $this->widget('CWidget'); ?></h1>

会提示 "Object of class CWidget could not be converted to string." 类 CWidget 的对象不能转化为字符串。

规则中的数字

在模型中的 rules 方法中使用 :

array('count', 'number', 'integerOnly'=>true),

然后试试

array('count', 'numeric', 'integerOnly'=>true),

最后再使用 'numerical'.  

查看更多关于Yii开发过程中的低级错误的详细内容...

  阅读:41次