忍者ブログ
忘れない為のお勉強思い出し日記
[29] [28] [27] [26] [25] [24] [23] [22]
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

・php詳細
$name = "";
$html->assign("name",$name);

・tpl詳細
デフォルト文<br>
{$name|default:"hoge"}<br>

・結果
デフォルト文<br>
hoge<br>
------------------------------
・php詳細
$lang = array("php","jsp","cgi",array("c","c++"));
$html->assign("lang",$lang);

・tpl詳細
単純配列文<br>
php     :       {$lang[0]}<br>
jsp     :       {$lang[1]}<br>
cgi:    :       {$lang[2]}<br>

c       :       {$lang[3][0]}<br>
c++     :       {$lang[3][1]}<br>

・結果
単純配列文<br>
php     :       php<br>
jsp     :       jsp<br>
cgi:    :       cgi<br>

c       :       c<br>
c++     :       c++<br>
------------------------------
・php詳細
$data = array("name"=>"hoge","tel"=>"000-0000-0000","mail"=>array("hoge@hoge.com","home"=>"hogehoge@hoge.com"));
$html->assign("data",$data);

・tpl詳細
連想配列文<br>
name    :       {$data.name}<br>
tel     :       {$data.tel}<br>
mail    :       {$data.mail[0]}<br>
mail    :       {$data.mail.home}<br>

・結果
連想配列文<br>
name    :       hoge<br>
tel     :       000-0000-0000<br>
mail    :       hoge@hoge.com<br>
mail    :       hogehoge@hoge.com<br>
------------------------------
・php詳細
class MyClass {
        public $name;
        private $tel;
        public function __construct($name,$tel){
                $this->name = $name;
                $this->tel = $tel;
        }
        public function getTel(){return $this->tel;}
}
$obj = new MyClass("hoge","000-000-0000");
$html->assign("obj",$obj);

・tpl詳細
オブジェクト文<br>
name    :       {$obj->name}<br>
tel     :       {$obj->getTel()}<br>

・結果
オブジェクト文<br>
name    :       hoge<br>
tel     :       000-000-0000<br>
------------------------------
・php詳細
define("NO",100);

・tpl詳細
PHP定数文<br>
{$smarty.const.NO}<br>

・結果
PHP定数文<br>
100<br>
------------------------------
・tpl詳細
現在のタイム文<br>
{$smarty.now}<br>

・結果
現在のタイム文<br>
1168417541<br>
------------------------------
・tpl詳細
実行中のテンプレート名文<br>
{$smarty.template}<br>

・結果
実行中のテンプレート名文<br>
hogehoge.tpl<br>
------------------------------
・tpl詳細
Smartyのバージョン情報文<br>
{$smarty.version}<br>

・結果
Smartyのバージョン情報文<br>
x.x.x<br>
------------------------------
・php詳細
$_GET['id'] = "'<id&pass>'+hoge";
$_POST['id'] = "'<id&pass>'+hoge";
$_REQUEST['id'] = "'<id&pass>'+hoge";

・tpl詳細
GET情報文<br>
{$smarty.get.id|escape}<br>
<br>
POST情報文<br>
{$smarty.post.id|escape:"htmlall"}<br>
<br>
REQUEST情報文<br>
{$smarty.request.id|escape:"javascript"}<br>

・結果
GET情報文<br>
&#039;&lt;id&amp;pass&gt;&#039;+hoge<br>

POST情報文<br>
&#039;&lt;id&amp;pass&gt;&#039;+hoge<br>

REQUEST情報文<br>
\'<id&pass>\'+hoge<br>
------------------------------
・php詳細
$lang = array("php","jsp","cgi",array("c","c++"));
$html->assign("lang",$lang);

・tpl詳細
単純配列カウント数文<br>
{$lang|@count}<br>

・結果
単純配列カウント数文<br>
4<br>
------------------------------
・php詳細
$data = array("name"=>"hoge","tel"=>"000-0000-0000","mail"=>array("hoge@hoge.com","home"=>"hogehoge@hoge.com"));
$html->assign("data",$data);

・tpl詳細
連想配列カウント数文<br>
{$data|@count}<br>

・結果連想配列カウント数文<br>
3<br>
------------------------------
・tpl詳細
日付文<br>
{$smarty.now|date_format:"%Y年%m月%d日 %H時:%M分:%S秒 %A"}<br>

・結果
日付文<br>
2007年01月10日 17時:25分:41秒 Wednesday<br>
------------------------------
・php詳細
$lang = array("php","jsp","cgi",array("c","c++"));
$html->assign("lang",$lang);

・tpl詳細
if文<br>
{if count($lang) > 2}
$langは2より大きいです<br>
{/if}

・結果
if文<br>
$langは2より大きいです<br>
------------------------------
・php詳細
$array_1 = array("name"=>"hoge","tel"=>"000-0000-0000","age"=>20);
$html->assign("array_1",$array_1);

・tpl詳細
foreach文<br>
{foreach from=$array_1 key="key" item="value" name="loop"}
KEY {$key} : VALUE {$value}<br>
{/foreach}

・結果
foreach文<br>
KEY name : VALUE hoge<br>
KEY tel : VALUE 000-0000-0000<br>
KEY age : VALUE 20<br>
------------------------------
・php詳細
$array_2 = array("hogehoge","111-1111-1111",25);
$array_3 = array("testtest","222-2222-2222",20);
$html->assign("array_2",$array_2);
$html->assign("array_3",$array_3);

・tpl詳細
section文<br>
{section name="data" loop=$array_2}
{$array_2[data]}<br>
{$array_3[data]}<br>
{/section}

・結果
section文<br>
hogehoge<br>
testtest<br>
111-1111-1111<br>
222-2222-2222<br>
25<br>
20<br>
------------------------------
・tpl詳細
mail文<br>
{mailto address="hoge@hoge.com" encode="hex"}<br>

・結果
mail文<br>
<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;%68%6f%67%65@%68%6f%67%65.%63%6f%6d" >&#x68;&#x6f;&#x67;&#x65;&#x40;&#x68;&#x6f;&#x67;&#x65;&#x2e;&#x63;&#x6f;&#x6d;</a><br>
------------------------------

PR

コメント


コメントフォーム
お名前
タイトル
文字色
メールアドレス
URL
コメント
パスワード
  Vodafone絵文字 i-mode絵文字 Ezweb絵文字


トラックバック
この記事にトラックバックする:


忍者ブログ [PR]
カレンダー
05 2026/06 07
S M T W T F S
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
フリーエリア
最新コメント
[11/18 DSLR-A900]
[12/04 cnanogetde]
[06/25 QzLNP]
[06/25 Jarmj]
[06/25 wncwh]
最新記事
最新トラックバック
プロフィール
性別:
男性
バーコード
ブログ内検索