Caching
 

キャッシング - 洛陽大通りネットワークは、ログイン|あなたのMVCとPHPの開始()を統合し、サイトの入り口

。MVCパターンに関する技術記事はどこを買うことができるので、このファイルは、もはや(長所と短所が、このモデルの話が、実際の
gbvy[W
私は、子供が自分のPHPの技術を語った)明らかでないとき。や記事のその後の一連の技術をベースについて語っている。




我々は、多くの場合、インターネット(パズル、いくつかの可能性があるようなサイトを実現する方法へのパスを表示することがあります:
図1は、ファイル拡張子を隠すには、このアプローチは、異なる意見の利点が、個人的に必要はないと思う。
2、サイトさんのルールを、仮想パスにリダイレクトして;
ファイルの解析を強制的に3つの方法は、仮想パス。
2 \ 3つの方法は、サイトと合理的な統合サイトに統一されたインタフェースを実現すると、よりこれらの2つのアプローチのほとんどのウェブサイト"MVCの"モデル構造の使用は、サイトのセキュリティと構造を反映




次のようにアクセスパスは:
....../test/*******/Bad
....../test/*******/Good
(これは任意の文字列の置換"******"の,"......."ウェブのパスを指定できます)
ファイルのディレクトリ構造は以下のとおりです。
|-- .htaccess
|-- test
|-- Application.php
|-- Controler/GoodControler.php
|-- Controler/BadControler.php

ファイルには、0:(。htaccessを)(このファイルは、Apacheを使用して構成を変更することです)
<files test>
forcetype application/x-httpd-php
</files>
ファイル1:(test.phpを)
<?php
/*
* test.php
*
サイトファイルの入り口*として
*初期化し、アクセスするために使用
*は、コールの実装をControlerコール
*
*/
require "Application.php";
$aa = new Application();
$aa->parse();
$aa->go();
?>

<?php
/*
* GoodControler.php
*

*
*/
class GoodControler{
/*
クラスの*コール制御方法、唯一の外部インターフェイスに行方不明と報告
*/
function control(){
echo "this is from GoodControler url=*********/test/Good";
}
}
?>
ファイル3:(BadControler.php)
<?php
/*
* BadControler.php
*
* = /テスト/アクセスして不正なURLを制御するために使用されます
*
*/
class BadControler{
/*

*/
function control(){
echo "this is from GoodControler url=*********/test/Bad";
}
}
?>
ファイル4:(Application.php)
<?php
/*
* Application.php
*
*統一されたポータルサイトを実装するために使用され、Controlerクラスと呼ばれる
*
*/
class Application{
/ /実施する操作を記録するために使用されます
var $action;
/ / Controlerファイルのパス名
var $controlerFile;
/ / Controlerクラス名
var $controlerClass;
function Application(){
}
function parse(){
$this->_parsePath();
$this->_getControlerFile();
$this->_getControlerClassname();
}
/*

*/
function _parsePath(){
list($path, $param) = explode("?", $_SERVER["REQUEST_URI"]);
$pos = strrpos($path, "/");
$this->action = substr($path, $pos+1);
}
/*

*/
function _getControlerFile(){
$this->controlerFile = "./Controler/".$this->action."Controler.php";
if(!file_exists($this->controlerFile))
("Controlerファイル名を("する$ this -> controlerFile")を構文解析エラー"。)死ぬ。
require_once $this->controlerFile;
}
/*
アクションの$ action *を通じて、クラス名を取得するための解析$ actionはcontrolerするために使用する
*/
function _getControlerClassname(){
$this->controlerClass = $this->action."Controler";
if(!class_exists($this->controlerClass))
死ぬ("Controlerクラス名("します$ this -> controlerClass")構文解析エラー"#:。。);
}
/*

*/
function go(){
$c = new $this->controlerClass();
$c->control();
}
}
?>