Sponsored Link
PHP XAMPPでSmartyを導入する方法
XAMPPにSmartyを導入させる
簡単な方法でいきます※それしか知らない
- 公式HPから最新のSmartyをダウンロードしましょう
Smarty 公式サイト - zipを解凍して、適当なところにおきましょう
- C:\xampp\htdocsにSmartyを入れるフォルダを作ります(仮にSmarty_Testとする)
- 解凍した中に“libs”というファイルがあるので、Smarty_Testに丸ごと入れます
- 更に“templates”と“templates_c”というフォルダをSmarty_Testの中に作ります
- “templates”の中にWEBページの元となるtplファイルを入れます(仮にindex.tplとします)
- Smarty_Testの中にindex.tpl通りに作動するphpファイルを置きます(仮にindex.phpとします)
- WEB上でhttp://localhost/smarty/index.phpが問題なく記載通りに開けたら完成
|-xampp | |-htdocs | | |-Smarty_Test | | | |-libs | | | | |-plugins | | | | |-sysplugins | | | | |-Autoloader.php | | | | |-Smarty.class.php | | | | |-SmartyBC.class.php | | | | |-debug.tpl | | | | | | | |-templates_c | | | |-templates | | | | |-index.tpl | | | | | | | |-index.php
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>smartyのテスト</title>
</head>
<body>
ようこそ、{$name}さん<br />
HelloWorld!
</body>
</html>
<?php
require "./libs/Smarty.class.php";
$smarty = new Smarty();
$smarty->assign('name', '私');
$smarty->display('index.tpl');