日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

保留变量

發布時間:2023/11/27 生活经验 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 保留变量 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

{$smarty} 保留變量

可以通過PHP的保留變量?{$smarty}來訪問一些環境變量。 下面是這些變量的列表:

頁面請求變量

頁面請求變量如$_GET,?$_POST,?$_COOKIE,?$_SERVER,?$_ENV?和?$_SESSION?可以通過下面的方式來使用:

Example?4.8.?顯示頁面請求變量

{* display value of page from URL ($_GET) http://www.example.com/index.php?page=foo *}
{$smarty.get.page}{* display the variable "page" from a form ($_POST['page']) *}
{$smarty.post.page}{* display the value of the cookie "username" ($_COOKIE['username']) *}
{$smarty.cookies.username}{* display the server variable "SERVER_NAME" ($_SERVER['SERVER_NAME'])*}
{$smarty.server.SERVER_NAME}{* display the system environment variable "PATH" *}
{$smarty.env.PATH}{* display the php session variable "id" ($_SESSION['id']) *}
{$smarty.session.id}{* display the variable "username" from merged get/post/cookies/server/env *}
{$smarty.request.username}

{$smarty.now}

當前的時間戳?可以通過{$smarty.now}來獲取。 時間戳是從1970年1月1日開始計算到當前的秒數。 當前時間戳可以被date_format?修飾器使用并顯示。 注意:在每次使用該變量時都會調用time()函數。 比如說一個程序花了三秒來執行,在開頭和結束時都調用了$smarty.now,那么這兩個數值將差三秒。

{* use the date_format modifier to show current date and time *}
{$smarty.now|date_format:'%Y-%m-%d %H:%M:%S'}

{$smarty.const}

直接訪問PHP的常量。參見?smarty 常量.

<?php
// the constant defined in php
define('MY_CONST_VAL','CHERRIES');
?>

在模板中顯示常量

{$smarty.const.MY_CONST_VAL}

{$smarty.capture}

Smarty內置函數?{capture}..{/capture}可以捕獲其中的代碼輸出。 通過{$smarty.capture}變量可以使用這些輸出的代碼。 參見?{capture}函數。

{$smarty.config}

{$smarty.config}變量可以獲取?配置變量。?{$smarty.config.foo}可獲取設置變量的{#foo#}。參見?{config_load}。

{$smarty.section}

{$smarty.section}變量是{section}?循環中的屬性。 它提供了一些很有用的值,如.first,?.index等等。

{$smarty.template}

返回當前的模板名稱(不帶目錄名)。

{$smarty.template_object}

返回當前模板對象。

{$smarty.current_dir}

返回當前模板的目錄名稱。

{$smarty.version}

<div id="footer">由 Smarty {$smarty.version} 引擎驅動</div>

返回編譯當前模板的Smarty版本。

{$smarty.block.child}

返回子模板提供的區塊代碼。 參見模板繼承。

{$smarty.block.parent}

返回父模板提供的區塊代碼。 參見模板繼承。

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

用于顯示左定界符和右定界符。等同于?{ldelim},{rdelim}

參見?賦值變量?和?配置變量

?

?

?

轉載于:https://www.cnblogs.com/gaocy/p/8167186.html

總結

以上是生活随笔為你收集整理的保留变量的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。