Home  >  Article  >  Backend Development  >  Smarty保留变量用法分析,smarty变量用法_PHP教程

Smarty保留变量用法分析,smarty变量用法_PHP教程

WBOY
WBOYOriginal
2016-07-12 08:50:38752browse

Smarty保留变量用法分析,smarty变量用法

本文实例讲述了Smarty保留变量用法。分享给大家供大家参考,具体如下:

{$smarty}变量无需分配,它可以直接在模板中,用于访问一些特殊的模板变量,有很多变量,比如说:页面请求变量$_GET,$_POST,$_REQUEST,$_SESSION,$_COOKIE,还有一些比如说环境变量$_ENV,$_SERVER,它们可以直接通过如下方式来获取:

{$smarty.get}

同$_GET获取url参数

如:$_GET['page']  通过{$smarty.get.page}获取

{$smarty.post}

同$_POST获取参数

{$smarty.request}

同$_REQUEST获取请求参数

{$smarty.cookie}

同$_COOKIE获取cookie

{$smarty.session}

同$_SESSION获取session

{$smarty.server}

同$_SERVER获取服务器变量

{$smarty.env}

同$_ENV获取环境变量

{$smarty.now}

同time(),获取时间戳

{$smarty.const}

直接访问PHP常量,如{$smarty.const.__FILE__}

{$smarty.capture}

通过内建的{capture}...{/capture}函数捕获的模板输出可以由{$smarty.capture.name}访问

{$smarty.section} {$smarty.foreach}

分别用来访问{section}和{foreach}的循环属性,有一些first,last,index等属性值可用

{$smarty.template}

返回当前模板名

{$smarty.version}

smarty版本

{$smarty.ldelim} {$smarty.rdelim}

用来打印左分隔符和右分隔符,类{ldelim}{rdelim}

更多关于Smarty相关内容感兴趣的读者可查看本站专题:《smarty模板入门基础教程》、《PHP模板技术总结》、《PHP基于pdo操作数据库技巧总结》、《PHP运算与运算符用法总结》、《PHP网络编程技巧总结》、《PHP基本语法入门教程》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于smarty模板的PHP程序设计有所帮助。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1133099.htmlTechArticleSmarty保留变量用法分析,smarty变量用法 本文实例讲述了Smarty保留变量用法。分享给大家供大家参考,具体如下: {$smarty}变量无需分配,它...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn