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

static クラス

static クラスには直接アクセスすることができます。構文は、PHP と同じです。

Note

PHP のクラスに直接アクセスすることはお勧めしません。 これは、アプリケーションのコードの構造と表示内容とを密結合させることになり、 さらにテンプレートの構造も複雑になってしまいます。 プラグインを登録し、テンプレートを PHP のクラスやオブジェクトから隔離することを推奨します。 この仕組みはよく考えた上で使うようにしましょう。 Smarty のウェブサイトにあるベストプラクティスのページも参照ください。

Example 15.12. static クラスへのアクセス方法


{assign var=foo value=myclass::BAR}  <--- クラス定数 BAR

{assign var=foo value=myclass::method()}  <--- メソッドの結果

{assign var=foo value=myclass::method1()->method2}  <--- メソッドチェイン

{assign var=foo value=myclass::$bar}  <--- myclass クラスの bar プロパティ

{assign var=foo value=$bar::method}  <--- Smarty の変数 bar をクラス名として使う


  

Comments
No comments for this page.

Advertisement

Sponsors [info]

Sponsors