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を用いるうえでの可視性の向上以外の利点は
ありますでしょうか?
また、改善点などございましたら、ご教授いただけると幸いです。
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
関連するカテゴリからQ&Aを探す
おすすめ情報
- ・漫画をレンタルでお得に読める!
- ・街中で見かけて「グッときた人」の思い出
- ・「一気に最後まで読んだ」本、教えて下さい!
- ・幼稚園時代「何組」でしたか?
- ・激凹みから立ち直る方法
- ・1つだけ過去を変えられるとしたら?
- ・【あるあるbot連動企画】あるあるbotに投稿したけど採用されなかったあるある募集
- ・【あるあるbot連動企画】フォロワー20万人のアカウントであなたのあるあるを披露してみませんか?
- ・映画のエンドロール観る派?観ない派?
- ・海外旅行から帰ってきたら、まず何を食べる?
- ・誕生日にもらった意外なもの
- ・天使と悪魔選手権
- ・ちょっと先の未来クイズ第2問
- ・【大喜利】【投稿~9/7】 ロボットの住む世界で流行ってる罰ゲームとは?
- ・推しミネラルウォーターはありますか?
- ・都道府県穴埋めゲーム
- ・この人頭いいなと思ったエピソード
- ・準・究極の選択
- ・ゆるやかでぃべーと タイムマシンを破壊すべきか。
- ・歩いた自慢大会
- ・許せない心理テスト
- ・字面がカッコいい英単語
- ・これ何て呼びますか Part2
- ・人生で一番思い出に残ってる靴
- ・ゆるやかでぃべーと すべての高校生はアルバイトをするべきだ。
- ・初めて自分の家と他人の家が違う、と意識した時
- ・単二電池
- ・チョコミントアイス
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
ZendFramework 環境設定
-
Ethnaの設定について
-
__FILE__をHTMLタグ内で使う
-
require_onceで読み込む場合、...
-
PHPファイルが、そのまま見えて...
-
[PHP] 任意のDNSでIPアドレスを...
-
pearライブラリのインクルード...
-
フォントの色を変えるには?
-
透過PNGが透過されない!!
-
FTPコマンドでディレクトリごと...
-
バッチを用いたフォルダの自動移動
-
PHPのif文でその処理を途中で抜...
-
別ファイルの変数を呼び出した...
-
.phpと.incファイルの違いはな...
-
一定時間毎に同じ動作を繰り返...
-
MySQLのdatetime型の月日0を削...
-
「クラス関数」「メンバ関数」...
-
リンク先を隠す方法はないでし...
-
ラッパークラスって何ですか?
-
Subversionのリポジトリの削除
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
__FILE__をHTMLタグ内で使う
-
codeigniterのsessionについて
-
CakePHPの表示エラーについて
-
動画共有サイトの作り方
-
index.phpに入るには、どうすれ...
-
.htaccessファイルの修正がこれ...
-
Ethnaの設定について
-
PHPファイルが、そのまま見えて...
-
ZendFramework 環境設定
-
PHPとMySQL
-
旧デザインの提携サイトはまだ...
-
特定のディレクトリだけ、phpを...
-
パスの書き方。
-
mod_rewriteによるURLの書き換え
-
ApacheのRewrite
-
歴史上の人物や宗教
-
センサーと表示部がコードレス...
-
include_pathに関する質問
-
ラミネート加工について
-
【初歩?】functionの使い方
おすすめ情報