You are currently viewing archive for February 2008

02/23: Smartyの設置方法

Category: PHP | Posted by: ayumi | 894 Comments
本家サイトから、Smarty本体を落してきてください。
 ↓
解凍すると
 Smarty-2.*.*
 ├demo/
├libs/
├misc/
├unit_test/
  └その他ファイル
が現れますが、使うのは「libs」フォルダです。
 ↓
「libs」をサーバにあげます。
 ↓
次に「tpl」と「tmp」フォルダを作成します。「tmp」をパーミションを707にします。
 ↓
Smartyファイルの読み込み。
require_once("./libs/Smarty.class.php");

 ↓
クラスの呼び出し。
$mySmarty=new Smarty();

 ↓
各種ファイルの場所を指定
tplの読み込み先
$mySmarty->compile_dir = ("./tpl");

キャッシュの吐き出し先
$mySmarty->template_dir = ("./tmp");

変数を渡します。
$mySmarty->assign("test","Smarty設置テスト");

使用するtplを指定
$mySmarty->display("../tpl/home.tpl");

 ↓
完了

02/21: CSVなどファイルの読み込みに使う階層の指定方法

Category: PHP | Posted by: ayumi | 1 Comment
dirname(__FILE__)で、そのファイルが存在する場所を取ってきます。

例)サンプル
require_once(dirname(__FILE__)."/config.php");




Search

Navigation

<   2008-02   >
     12
3456789
10111213141516
17181920212223
242526272829