Get Smarty

Donate

Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Advertisement

Name

createData() — データオブジェクトを作成する

説明

string createData(object parent);
string createData();

この関数は、代入された変数を保持するデータオブジェクトを作成します。 次のパラメータを使います。

  • parent はオプションのパラメータで、 メイン Smarty オブジェクトやユーザが作成したデータオブジェクト、 あるいはユーザが作成したテンプレートオブジェクトなどへのアップリンクです。 これらのオブジェクトは連結することができます。 テンプレートからは、連結したオブジェクト内で代入されたすべての値にアクセスできます。

データオブジェクトを使うと、代入された変数用のスコープを作ることができます。 これを用いて、どの変数がどのテンプレートから使えるかを制御することができます。

Example 13.14. createData()


<?php
include('Smarty.class.php');
$smarty = new Smarty;

// 閉じたスコープ用に、データオブジェクトを作成します
$data = $smarty->createData();

// data のスコープに変数を代入します
$data->assign('foo','bar');

// このデータオブジェクトを使うテンプレートを作成します
$tpl = $smarty->createTemplate('index.tpl',$data);

// テンプレートを表示します
$tpl->display();
?>

    


display(), および createTemplate() も参照ください。

Comments
No comments for this page.

Advertisement

Sponsors [info]

Sponsors