【大喜利】【投稿~9/7】 ロボットの住む世界で流行ってる罰ゲームとは?

phpを用いて携帯サイトを作成しています。

phpのみを表記している「a.php」「b.php」「c.php」「d.php」「e.php」があります。
------------a.php-------------
<?php
if(~~){
$a[0] = '~~';
}else(~~~~){
$a[0] = '~~~';
}
$a[1] = '~~';
$a[2] = '~~~';



$a[n-10] = <<< MESSAGE
<h1>{$a[n-25}</h1>
<p>テスト表示</p>
    ・
    ・
<p>{$a[n-15]}</p>
MESSAGE;


$a[n] = <<< MESSAGE
<h1>{$a[n-50}</h1>
<p>テスト表示</p>
    ・
    ・
<p>{$a[n-45]}</p>
MESSAGE;
?>
-----------------------------------
------------b.php------------------
<?php
if(~~){
$b[0] = '~~';
}else(~~~~){
$b[0] = '~~~';
}
$b[1] = '~~';
$b[2] = '~~~';



$b[n] = <<< MESSAGE
<h1>{$b[0}</h1>
<p>テスト表示</p>
    ・
    ・
<p>{$b[n-10]}</p>
MESSAGE;
?>
---------------------------------------
c.php以下の内容もだいたいおなじ内容になっております。


-----------index.php--------------------
<html>
<head>
<?php
include_once 'a.php';
include_once 'b.php';
include_once 'c.php';
include_once 'd.php';
include_once 'e.php';
?>
</head>
<body>
<?php
echo $a[0];
echo $a[n];
echo $b[n-60];
echo $c[n-30];
?>
</body>
</html>
-----------------------------------------
-----------index1.php-------------------
<html>
<head>
<?php
include_once 'a.php';
include_once 'b.php';
include_once 'c.php';
include_once 'd.php';
include_once 'e.php';
?>
</head>
<body>
<?php
echo $a[0];
echo $a[n];
echo $b[n-80];
echo $c[n-3];
?>
</body>
</html>
-------------------------------------

このような感じでindex.php ~ index[n].phpを作成しております。
index.php ~ index[n].phpは、基本として修正は行なわず
a.php ~ e.phpを修正することによって、すべてのページへ
瞬時に反映できるようにして作成しております。
現在、この方法で十分管理はできています。

つぎは、smartyを用いておなじような処理を考えてみました。

########################
### smarty使用 ####
########################
------------index.php開始----------------
<?php
require_once 'libs/Smarty.class.php';
$smarty = new Smarty;
$smarty->compile_check = true;
include_once 'a.php';
include_once 'b.php';
include_once 'c.php';
include_once 'd.php';
include_once 'e.php';

$smarty->assign("a", $a);
$smarty->assign("b",$b);
$smarty->assign("c",$c);

$smarty->display('test.tpl');
?>
------------------------------------------
------------index.tpl---------------------
<html>
<head>
</head>
<body>
{$a[0]}
{$a[n]}
{$b[n-60]}
{$c[n-30]}
</body>
</html>
---------------------------------------
smartyを使っていないときよりも、smartyを使ったほうが
処理速度が速くなるようでしたらsmartyに乗り換えるのですが
Smarty.class.phpを余分に読み込む分、処理速度が速くなって
いるとも思えません。
また、index.html ~ index[n].htmlへの記述も大差ないので
可視性やデザイン面でもとくに違和感なく修正できます。

上記の作成方法で、smartyを用いるうえでの可視性の向上以外の利点は
ありますでしょうか?

また、改善点などございましたら、ご教授いただけると幸いです。

A 回答 (2件)

ロジックとhtml(ビュー)を分離できるからいいのです


1人で開発するようであれば、あまり特しないかもしれませんが
多人数で開発するときは、デザイナー、プログラマー入り乱れますよね?
デザイナーは普通プログラミングできませんがhtmlは書きます
その時に最低限のルールを伝えればデザイナーが*.tpl作ってくれるので楽ができます
    • good
    • 0

smartyの利点はメンテナンス性と開発するうえでの設計モデルとして


MVCと言う物を知っていますか?
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!


おすすめ情報