Yii模板能不能够支持原生语法-创新互联

这篇文章给大家分享的是有关Yii模板能不能够支持原生语法的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

创新互联建站长期为上1000家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为市中企业提供专业的成都网站设计、成都网站建设、外贸网站建设市中网站改版等技术服务。拥有10年丰富建站经验和众多成功案例,为您定制开发。

Yii 模板支持原生语法吗?

Yii模板支持原生语法,因为Yii框架并没有使用模板引擎,所以能够在Yii模板中使用原生PHP语法,Yii模板并没有使用像Smarty那样将自定义的标签编译成PHP,而是对PHP原生态语法的封装。


Yii 模板标签

label标签

<?php echo $form->labelEx($model,'name'); ?>

编译后:

<label for="Project_name" class="required">项目名称 <span class="required">*</span></label>

文本标签

<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>128)); ?>

编译后:

<input size="60" maxlength="128" name="Project[name]" id="Project_name" type="text">

error标签

<?php echo $form->error($model,'name'); ?>

编译后:

<div class="errorMessage">{变量}</div>

textarea标签

<?php echo $form->textArea($model,'description',array('rows'=>6, 'cols'=>50)); ?>

编译后:

<textarea rows="6" cols="50" name="Project[description]" id="Project_description" class="error"></textarea>

hidden标签

<?php echo $form->hiddenField($model,'create_time',array('value'=>time())); ?>

编译后:

<input value="1376475100" name="Project[create_time]" id="Project_create_time" type="hidden">

password标签

<?php echo $form->passwordField($model,'password'); ?>

编译后:

<input name="Project[password]" id="Project_password" type="password">

url标签

<?php echo $form->urlField($model,'url'); ?>

编译后:

<input name="Project[url]" id="Project_url" type="url">

radio标签

<?php echo $form->radioButtonList($model, 'update_time', array('1'=>'分页','0'=>'不分页')); ?>

编译后:

<input id="ytProject_update_time" type="hidden" value="" name="Project[update_time]">
<span id="Project_update_time"><input id="Project_update_time_0" value="1" type="radio" name="Project[update_time]"> <label for="Project_update_time_0">分页</label><br>
<input id="Project_update_time_1" value="0" type="radio" name="Project[update_time]"> 
<label for="Project_update_time_1">不分页</label></span>

file标签

<?php echo $form->fileField($model, 'update_time'); ?>

编译后:

<input id="ytProject_update_time" type="hidden" value="" name="Project[update_time]">
<input name="Project[update_time]" id="Project_update_time" type="file">

button标签

<?php echo CHtml::submitButton($model->isNewRecord ? '创建' : '保存'); ?>

编译后:

<input type="submit" name="yt0" value="创建">

checkBox标签

<?php echo $form->checkBox($model, 'update_time',array('checked'=>'checked')); ?>

编译后:

<input id="ytProject_update_time" type="hidden" value="0" name="Project[update_time]">
<input checked="checked" name="Project[update_time]" id="Project_update_time" value="1" type="checkbox">

select标签

<?php echo $form->dropDownList($model, 'update_time', array('1'=>'分页','0'=>'不分页')); ?>

编译后:

<select name="Project[update_time]" id="Project_update_time">
<option value="1">分页</option>
<option value="0">不分页</option>
</select>

select标签

<?php echo $form->listBox($model, 'update_time', array('1'=>'分页','0'=>'不分页')); ?>

编译后:

<select size="4" name="Project[update_time]" id="Project_update_time">
<option value="1">分页</option>
<option value="0">不分页</option>
</select>

checkbox标签

<?php echo $form->checkBoxList($model, 'update_time', array('1'=>'分页','0'=>'不分页')); ?>

编译后:

<input id="ytProject_update_time" type="hidden" value="" name="Project[update_time]"><span id="Project_update_time"><input id="Project_update_time_0" value="1" type="checkbox" name="Project[update_time][]"> <label for="Project_update_time_0">分页</label><br>
<input id="Project_update_time_1" value="0" type="checkbox" name="Project[update_time][]"> <label for="Project_update_time_1">不分页</label></span>

date标签

 <?php echo $form->dateField($model, 'update_time'); ?>

编译后:

<input name="Project[update_time]" id="Project_update_time" type="date">

number标签

<?php echo $form->numberField($model, 'number'); ?>

编译后:

<input name="Project[number]" id="Project_number" type="number">

email标签

<?php echo $form->emailField($model, 'email'); ?>

编译后:

<input name="Project[email]" id="Project_email" type="email">

label标签

 <?php echo $form->label($model, 'update_time'); ?>

编译后:

<label for="Project_update_time">更新时间</label>

感谢各位的阅读!关于“Yii模板能不能够支持原生语法”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

分享标题:Yii模板能不能够支持原生语法-创新互联
URL网址:https://www.cdcxhl.com/article36/ceoipg.html

成都网站建设公司_创新互联,为您提供网站设计网站内链手机网站建设ChatGPT服务器托管品牌网站建设

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

网站建设网站维护公司