\r\n  

    This is an example.<\/p>\r\n<\/body>\r\n<\/html><\/pre>

       <\/p>

    <\/p>

    現(xiàn)在,如果你訪問自己網(wǎng)站的根資源,你會看到example.php的內(nèi)容。這仍沒什么用,但你要清楚你要在以一種結(jié)構(gòu)和組織非常清楚的方式在開發(fā)網(wǎng)絡(luò)應(yīng)用。<\/p>

    為了讓Zend_View的應(yīng)用更清楚一點,,修改你的模板(example.php)包含以下內(nèi)容:<\/p>

    \r\n\r\n  <?php echo $this->escape($this->title); ?><\/title>\r\n<\/head>\r\n<body>
    <h1><a href="http://m.miracleart.cn/">国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂</a></h1>\r\n  <?php echo $this->escape($this->body); ?>\r\n<\/body>\r\n<\/html><\/pre><p>   <\/p><p><\/p><p>現(xiàn)在已經(jīng)添加了兩個功能。$this->escape()類方法用于所有的輸出。即使你自己創(chuàng)建輸出,就像這個例子一樣。避開所有輸出也是一個很好的習慣,它可以在默認情況下幫助你防止跨站腳本攻擊(XSS)。<\/p><p>$this->title和$this->body屬性用來展示動態(tài)數(shù)據(jù)。這些也可以在controller中定義,所以我們修改IndexController.php以指定它們:<\/p><pre class='brush:php;toolbar:false;'><?php\r\nZend::loadClass('Zend_Controller_Action');\r\nZend::loadClass('Zend_View');\r\nclass IndexController extends Zend_Controller_Action\r\n{\r\n  public function indexAction()\r\n  {\r\n    $view = new Zend_View();\r\n    $view->setScriptPath('\/path\/to\/views');\r\n    $view->title = 'Dynamic Title';\r\n    $view->body = 'This is a dynamic body.';\r\n    echo $view->render('example.php');\r\n  }\r\n  public function noRouteAction()\r\n  {\r\n    $this->_redirect('\/');\r\n  }\r\n}\r\n?><\/pre><p>   <\/p><p><\/p><p>現(xiàn)在你再次訪問根目錄,應(yīng)該就可以看到模板所使用的這些值了。因為你在模板中使用的$this就是在Zend_View范圍內(nèi)所執(zhí)行的實例。<\/p><p>要記住example.php只是一個普通的PHP腳本,所以你完全可以做你想做的。只是應(yīng)努力只在要求顯示數(shù)據(jù)時才使用模板。你的controller (controller分發(fā)的模塊)應(yīng)處理你全部的業(yè)務(wù)邏輯。<\/p><p>在繼續(xù)之前,我想做最后一個關(guān)于Zend_View的提示。在controller的每個類方法內(nèi)初始化$view對象需要額外輸入一些內(nèi)容,而我們的主要目標是讓快速開發(fā)網(wǎng)絡(luò)應(yīng)用更簡單。如果所有模板都放在一個目錄下,是否要在每個例子中都調(diào)用setScriptPath()也存在爭議。<\/p><p>幸運的是,Zend類包含了一個寄存器來幫助減少工作量。你可以用register()方法把你的$view對象存儲在寄存器:<\/p><pre class='brush:php;toolbar:false;'><?php\r\nZend::register('view', $view);\r\n?><\/pre><p>   <\/p><p><\/p><p>用registry()方法進行檢索:<\/p><pre class='brush:php;toolbar:false;'><?php\r\n$view = Zend::registry('view');\r\n?><\/pre><p>   <\/p><p><\/p><p>基于這點,本教程使用寄存器。 <\/p><p>Zend_InputFilter<\/p><p>本教程討論的最后一個組件是Zend_InputFilter。這個類提供了一種簡單而有效的輸入過濾方法。你可以通過提供一組待過濾數(shù)據(jù)來進行初始化。<\/p><pre class='brush:php;toolbar:false;'><?php\r\n$filterPost = new Zend_InputFilter($_POST);\r\n?><\/pre><p>   <\/p><p><\/p><p>這會將($_POST)設(shè)置為NULL,所以就不能直接進入了。Zend_InputFilter提供了一個簡單、集中的根據(jù)特定規(guī)則過濾數(shù)據(jù)的類方法集。例如,你可以用getAlpha()來獲取$_POST['name']中的字母:<\/p><pre class='brush:php;toolbar:false;'><?php\r\n\/* $_POST['name'] = 'John123Doe'; *\/\r\n$filterPost = new Zend_InputFilter($_POST);\r\n\/* $_POST = NULL; *\/\r\n$alphaName = $filterPost->getAlpha('name');\r\n\/* $alphaName = 'JohnDoe'; *\/\r\n?><\/pre><p>   <\/p><p><\/p><p>每一個類方法的參數(shù)都是對應(yīng)要過濾的元素的關(guān)鍵詞。對象(例子中的$filterPost)可以保護數(shù)據(jù)不被篡改,并能更好地控制對數(shù)據(jù)的操作及一致性。因此,當你操縱輸入數(shù)據(jù),應(yīng)始終使用Zend_InputFilter。<\/p><p>提示:Zend_Filter提供與Zend_InputFilter方法一樣的靜態(tài)方法。<\/p><p>構(gòu)建新聞管理系統(tǒng)<\/p><p>雖然預覽版提供了許多組件(甚至許多已經(jīng)被開發(fā)),我們已經(jīng)討論了構(gòu)建一個簡單程序所需要的全部組件。在這里,你會對ZF的基本結(jié)構(gòu)和設(shè)計有更清楚的理解。<\/p><p>每個人開發(fā)的程序都會有所不同,而Zend Framework試圖包容這些差異。同樣,這個教程是根據(jù)我的喜好寫的,請根據(jù)自己的偏好自行調(diào)整。<\/p><p>當我開發(fā)程序時,我會先做界面。這并不意味著我把時間都花在標簽、樣式表和圖片上,而是我從一個用戶的角度去考慮問題。因此我把程序看成是頁面的集合,每一頁都是一個獨立的網(wǎng)址。這個新聞系統(tǒng)就是由以下網(wǎng)址組成的:<\/p><p>\/<br\/>\/add\/news<br\/>\/add\/comment<br\/>\/admin<br\/>\/admin\/approve<br\/>\/view\/{id}<\/p><p>你可以直接把這些網(wǎng)址和controller聯(lián)系起來。IndexController列出新聞,AddController添加新聞和評論,AdminController處理一些如批準新聞之類的管理,ViewController特定新聞和對應(yīng)評論的顯示。<\/p><p>如果你的FooController.php還在,把它刪除。修改IndexController.php,為業(yè)務(wù)邏輯以添加相應(yīng)的action和一些注釋:<\/p><pre class='brush:php;toolbar:false;'><?php\r\nZend::loadClass('Zend_Controller_Action');\r\nclass IndexController extends Zend_Controller_Action\r\n{\r\n  public function indexAction()\r\n  {\r\n    \/* List the news. *\/\r\n  }\r\n  public function noRouteAction()\r\n  {\r\n    $this->_redirect('\/');\r\n  }\r\n}\r\n?><\/pre><p>   <\/p><p><\/p><p>接下來,創(chuàng)建AddController.php文件:<\/p><pre class='brush:php;toolbar:false;'><?php\r\nZend::loadClass('Zend_Controller_Action');\r\nclass AddController extends Zend_Controller_Action\r\n{\r\n  function indexAction()\r\n  {\r\n    $this->_redirect('\/');\r\n  }\r\n  function commentAction()\r\n  {\r\n    \/* Add a comment. *\/\r\n  }\r\n  function newsAction()\r\n  {\r\n    \/* Add news. *\/\r\n  }\r\n  function __call($action, $arguments)\r\n  {\r\n    $this->_redirect('\/');\r\n  }\r\n}\r\n?><\/pre><p>   <\/p><p><\/p><p>記住AddController的indexAction()方法不能調(diào)用。當訪問\/add時會執(zhí)行這個類方法。因為用戶可以手工訪問這個網(wǎng)址,這是有可能的,所以你要把用戶重定向到主頁、顯示錯誤或你認為合適的行為。<\/p><p>接下來,創(chuàng)建AdminController.php文件:<\/p><pre class='brush:php;toolbar:false;'><?php\r\nZend::loadClass('Zend_Controller_Action');\r\nclass AdminController extends Zend_Controller_Action\r\n{\r\n  function indexAction()\r\n  {\r\n    \/* Display admin interface. *\/\r\n  }\r\n  function approveAction()\r\n  {\r\n    \/* Approve news. *\/\r\n  }\r\n  function __call($action, $arguments)\r\n  {\r\n    $this->_redirect('\/');\r\n  }\r\n}\r\n?><\/pre><p>   <\/p><p><\/p><p>最后,創(chuàng)建ViewController.php文件:<\/p><pre class='brush:php;toolbar:false;'><?php\r\nZend::loadClass('Zend_Controller_Action');\r\nclass ViewController extends Zend_Controller_Action\r\n{\r\n  function indexAction()\r\n  {\r\n    $this->_redirect('\/');\r\n  }\r\n  function __call($id, $arguments)\r\n  {\r\n    \/* Display news and comments for $id. *\/\r\n  }\r\n}\r\n?><\/pre><p>   <\/p><p><\/p><p>和AddController一樣,index()方法不能調(diào)用,所以你可以使用你認為合適的action。ViewController和其它的有點不同,因為你不知道什么才是有效的action。為了支持像\/view\/23這樣的網(wǎng)址,你要使用__call()來支持動態(tài)action。<\/p><p>數(shù)據(jù)庫操作<\/p><p>因為Zend Framework的數(shù)據(jù)庫組件還不穩(wěn)定,而我希望這個演示可以做得簡單一點。我使用了一個簡單的類,用SQLite進行新聞條目和評論的存儲和查詢。<\/p><pre class='brush:php;toolbar:false;'><?php\r\nclass Database\r\n{\r\n  private $_db;\r\n  public function __construct($filename)\r\n  {\r\n    $this->_db = new SQLiteDatabase($filename);\r\n  }\r\n  public function addComment($name, $comment, $newsId)\r\n  {\r\n    $name = sqlite_escape_string($name);\r\n    $comment = sqlite_escape_string($comment);\r\n    $newsId = sqlite_escape_string($newsId);\r\n    $sql = \"INSERT\r\n        INTO  comments (name, comment, newsId)\r\n        VALUES ('$name', '$comment', '$newsId')\";\r\n    return $this->_db->query($sql);\r\n  }\r\n  public function addNews($title, $content)\r\n  {\r\n    $title = sqlite_escape_string($title);\r\n    $content = sqlite_escape_string($content);\r\n    $sql = \"INSERT\r\n        INTO  news (title, content)\r\n        VALUES ('$title', '$content')\";\r\n    return $this->_db->query($sql);\r\n  }\r\n  public function approveNews($ids)\r\n  {\r\n    foreach ($ids as $id) {\r\n      $id = sqlite_escape_string($id);\r\n      $sql = \"UPDATE news\r\n          SET  approval = 'T'\r\n          WHERE id = '$id'\";\r\n      if (!$this->_db->query($sql)) {\r\n        return FALSE;\r\n      }\r\n    }\r\n    return TRUE;\r\n  }\r\n  public function getComments($newsId)\r\n  {\r\n    $newsId = sqlite_escape_string($newsId);\r\n    $sql = \"SELECT name, comment\r\n        FROM  comments\r\n        WHERE newsId = '$newsId'\";\r\n    if ($result = $this->_db->query($sql)) {\r\n      return $result->fetchAll();\r\n    }\r\n    return FALSE;\r\n  }\r\n  public function getNews($id = 'ALL')\r\n  {\r\n    $id = sqlite_escape_string($id);\r\n    switch ($id) {\r\n      case 'ALL':\r\n        $sql = \"SELECT id,\r\n                title\r\n            FROM  news\r\n            WHERE approval = 'T'\";\r\n        break;\r\n      case 'NEW':\r\n        $sql = \"SELECT *\r\n            FROM  news\r\n            WHERE approval != 'T'\";\r\n        break;\r\n      default:\r\n        $sql = \"SELECT *\r\n            FROM  news\r\n            WHERE id = '$id'\";\r\n        break;\r\n    }\r\n    if ($result = $this->_db->query($sql)) {\r\n      if ($result->numRows() != 1) {\r\n        return $result->fetchAll();\r\n      } else {\r\n        return $result->fetch();\r\n      }\r\n    }\r\n    return FALSE;\r\n  }\r\n}\r\n?><\/pre><p>   <\/p><p><\/p><p>(你可以用自己的解決方案隨意替換這個類。這里只是為你提供一個完整示例的介紹,并非建議要這么實現(xiàn)。)<\/p><p>這個類的構(gòu)造器需要SQLite數(shù)據(jù)庫的完整路徑和文件名,你必須自己進行創(chuàng)建。<\/p><pre class='brush:php;toolbar:false;'><?php\r\n$db = new SQLiteDatabase('\/path\/to\/db.sqlite');\r\n$db->query(\"CREATE TABLE news (\r\n    id    INTEGER PRIMARY KEY,\r\n    title  VARCHAR(255),\r\n    content TEXT,\r\n    approval CHAR(1) DEFAULT 'F'\r\n  )\");\r\n$db->query(\"CREATE TABLE comments (\r\n    id    INTEGER PRIMARY KEY,\r\n    name   VARCHAR(255),\r\n    comment TEXT,\r\n    newsId  INTEGER\r\n  )\");\r\n?><\/pre><p>   <\/p><p><\/p><p>你只需要做一次,以后直接給出Database類構(gòu)造器的完整路徑和文件名即可:<\/p><pre class='brush:php;toolbar:false;'><?php\r\n$db = new Database('\/path\/to\/db.sqlite');\r\n?><\/pre><p>   <\/p><p><\/p><p>整合<\/p><p>為了進行整合,在lib目錄下創(chuàng)建Database.php,loadClass()就可以找到它。你的index.php文件現(xiàn)在就會初始化$view和$db并存儲到寄存器。你也可以創(chuàng)建__autoload()函數(shù)自動加載你所需要的類:<\/p><pre class='brush:php;toolbar:false;'><?php\r\ninclude 'Zend.php';\r\nfunction __autoload($class)\r\n{\r\n  Zend::loadClass($class);\r\n}\r\n$db = new Database('\/path\/to\/db.sqlite');\r\nZend::register('db', $db);\r\n$view = new Zend_View;\r\n$view->setScriptPath('\/path\/to\/views');\r\nZend::register('view', $view);\r\n$controller = Zend_Controller_Front::getInstance()\r\n       ->setControllerDirectory('\/path\/to\/controllers')\r\n       ->dispatch();\r\n?><\/pre><p>   <\/p><p><\/p><p>接下來,在views目錄創(chuàng)建一些簡單的模板。index.php可以用來顯示index視圖:<\/p><pre class='brush:php;toolbar:false;'><html>\r\n<head>\r\n <title>News<\/title>\r\n<\/head>\r\n<body>\r\n <h1>News<\/h1>\r\n <?php foreach ($this->news as $entry) { ?>\r\n <p>\r\n  <a href=\"\/view\/<?php echo $this->escape($entry['id']); ?>\">\r\n  <?php echo $this->escape($entry['title']); ?>\r\n  <\/a>\r\n <\/p>\r\n <?php } ?>\r\n <h1>Add News<\/h1>\r\n <form action=\"\/add\/news\" method=\"POST\">\r\n <p>Title:<br \/><input type=\"text\" name=\"title\" \/><\/p>\r\n <p>Content:<br \/><textarea name=\"content\"><\/textarea><\/p>\r\n <p><input type=\"submit\" value=\"Add News\" \/><\/p>\r\n <\/form>\r\n<\/body>\r\n<\/html><\/pre><p>   <\/p><p><\/p><p>view.php模板可以用來顯示選定的新聞條目:<\/p><pre class='brush:php;toolbar:false;'><html>\r\n<head>\r\n <title>\r\n  <?php echo $this->escape($this->news['title']); ?>\r\n <\/title>\r\n<\/head>\r\n<body>\r\n <h1>\r\n  <?php echo $this->escape($this->news['title']); ?>\r\n <\/h1>\r\n <p>\r\n  <?php echo $this->escape($this->news['content']); ?>\r\n <\/p>\r\n <h1>Comments<\/h1>\r\n <?php foreach ($this->comments as $comment) { ?>\r\n <p>\r\n  <?php echo $this->escape($comment['name']); ?> writes:\r\n <\/p>\r\n <blockquote>\r\n  <?php echo $this->escape($comment['comment']); ?>\r\n <\/blockquote>\r\n <?php } ?>\r\n <h1>Add a Comment<\/h1>\r\n <form action=\"\/add\/comment\" method=\"POST\">\r\n <input type=\"hidden\" name=\"newsId\"\r\n  value=\"<?php echo $this->escape($this->id); ?>\" \/>\r\n <p>Name:<br \/><input type=\"text\" name=\"name\" \/><\/p>\r\n <p>Comment:<br \/><textarea name=\"comment\"><\/textarea><\/p>\r\n <p><input type=\"submit\" value=\"Add Comment\" \/><\/p>\r\n <\/form>\r\n<\/body>\r\n<\/html><\/pre><p>   <\/p><p><\/p><p>最后,admin.php模板可以用來批準新聞條目:<\/p><pre class='brush:php;toolbar:false;'><html>\r\n<head>\r\n <title>News Admin<\/title>\r\n<\/head>\r\n<body>\r\n <form action=\"\/admin\/approve\" method=\"POST\">\r\n <?php foreach ($this->news as $entry) { ?>\r\n <p>\r\n  <input type=\"checkbox\" name=\"ids[]\"\r\n  value=\"<?php echo $this->escape($entry['id']); ?>\" \/>\r\n  <?php echo $this->escape($entry['title']); ?>\r\n  <?php echo $this->escape($entry['content']); ?>\r\n <\/p>\r\n <?php } ?>\r\n <p>\r\n  Password:<br \/><input type=\"password\" name=\"password\" \/>\r\n <\/p>\r\n <p><input type=\"submit\" value=\"Approve\" \/><\/p>\r\n <\/form>\r\n<\/body>\r\n<\/html><\/pre><p>   <\/p><p><\/p><p>提示:為了保持簡單,這個表單用密碼作為驗證機制。<\/p><p>使用到模板的地方,你只需要把注釋替換成幾行代碼。如IndexController.php就變成下面這樣:<\/p><pre class='brush:php;toolbar:false;'><?php\r\nclass IndexController extends Zend_Controller_Action\r\n{\r\n  public function indexAction()\r\n  {\r\n    \/* List the news. *\/\r\n    $db = Zend::registry('db');\r\n    $view = Zend::registry('view');\r\n    $view->news = $db->getNews();\r\n    echo $view->render('index.php');\r\n  }\r\n  public function noRouteAction()\r\n  {\r\n    $this->_redirect('\/');\r\n  }\r\n}\r\n?><\/pre><p>   <\/p><p><\/p><p>因為條理比較清楚,這個程序首頁的整個業(yè)務(wù)邏輯只有四行代碼。AddController.php更復雜一點,它需要更多的代碼:<\/p><pre class='brush:php;toolbar:false;'><?php\r\nclass AddController extends Zend_Controller_Action\r\n{\r\n  function indexAction()\r\n  {\r\n    $this->_redirect('\/');\r\n  }\r\n  function commentAction()\r\n  {\r\n    \/* Add a comment. *\/\r\n    $filterPost = new Zend_InputFilter($_POST);\r\n    $db = Zend::registry('db');\r\n    $name = $filterPost->getAlpha('name');\r\n    $comment = $filterPost->noTags('comment');\r\n    $newsId = $filterPost->getDigits('newsId');\r\n    $db->addComment($name, $comment, $newsId);\r\n    $this->_redirect(\"\/view\/$newsId\");\r\n  }\r\n  function newsAction()\r\n  {\r\n    \/* Add news. *\/\r\n    $filterPost = new Zend_InputFilter($_POST);\r\n    $db = Zend::registry('db');\r\n    $title = $filterPost->noTags('title');\r\n    $content = $filterPost->noTags('content');\r\n    $db->addNews($title, $content);\r\n    $this->_redirect('\/');\r\n  }\r\n  function __call($action, $arguments)\r\n  {\r\n    $this->_redirect('\/');\r\n  }\r\n}\r\n?><\/pre><p>   <\/p><p><\/p><p>因為用戶在提交表單后被重定向,這個controller不需要視圖。<\/p><p>在AdminController.php,你要處理顯示管理界面和批準新聞兩個action:<\/p><pre class='brush:php;toolbar:false;'><?php\r\nclass AdminController extends Zend_Controller_Action\r\n{\r\n  function indexAction()\r\n  {\r\n    \/* Display admin interface. *\/\r\n    $db = Zend::registry('db');\r\n    $view = Zend::registry('view');\r\n    $view->news = $db->getNews('NEW');\r\n    echo $view->render('admin.php');\r\n  }\r\n  function approveAction()\r\n  {\r\n    \/* Approve news. *\/\r\n    $filterPost = new Zend_InputFilter($_POST);\r\n    $db = Zend::registry('db');\r\n    if ($filterPost->getRaw('password') == 'mypass') {\r\n      $db->approveNews($filterPost->getRaw('ids'));\r\n      $this->_redirect('\/');\r\n    } else {\r\n      echo 'The password is incorrect.';\r\n    }\r\n  }\r\n  function __call($action, $arguments)\r\n  {\r\n    $this->_redirect('\/');\r\n  }\r\n}\r\n?><\/pre><p>   <\/p><p><\/p><p>最后是ViewController.php:<\/p><pre class='brush:php;toolbar:false;'><?php\r\nclass ViewController extends Zend_Controller_Action\r\n{\r\n  function indexAction()\r\n  {\r\n    $this->_redirect('\/');\r\n  }\r\n  function __call($id, $arguments)\r\n  {\r\n    \/* Display news and comments for $id. *\/\r\n    $id = Zend_Filter::getDigits($id);\r\n    $db = Zend::registry('db');\r\n    $view = Zend::registry('view');\r\n    $view->news = $db->getNews($id);\r\n    $view->comments = $db->getComments($id);\r\n    $view->id = $id;\r\n    echo $view->render('view.php');\r\n  }\r\n}\r\n?><\/pre><p>? ?<\/p>\n<p><\/p>\n<p>雖然很簡單,但我們還是提供了一個功能較全的新聞和評論程序。最好的地方是由于有較好的設(shè)計,增加功能變得很簡單。而且隨著Zend Framework越來越成熟,只會變得更好。<\/p>\n<p>更多信息<\/p>\n<p>這個教程只是討論了ZF表面的一些功能,但現(xiàn)在也有一些其它的資源可供參考。在http:\/\/framework.zend.com\/manual\/有手冊可以查詢,Rob Allen在http:\/\/akrabat.com\/zend-framework\/介紹了一些他使用Zend Framework的經(jīng)驗,而Richard Thomas也在http:\/\/www.cyberlot.net\/zendframenotes提供了一些有用的筆記。如果你有自己的想法,可以訪問Zend Framework的新論壇:http:\/\/www.phparch.com\/discuss\/index.php\/f\/289\/\/。<\/p>\n<p>結(jié)束語<\/p>\n<p>要對預覽版進行評價是很容易的事,我在寫這個教程時也遇到很多困難??偟膩碚f,我想Zend Framework顯示了承諾,加入的每個人都是想繼續(xù)完善它。<\/p>\n<p>I hope this article will be helpful to everyone’s PHP programming based on the Zend Framework framework. <\/p>\n<p>For more articles related to Zend Framework development introductory classic tutorials, please pay attention to the PHP Chinese website! <\/p>"}	</script>
    	
    <meta http-equiv="Cache-Control" content="no-transform" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <script>var V_PATH="/";window.onerror=function(){ return true; };</script>
    </head>
    
    <body data-commit-time="2023-12-28T14:50:12+08:00" class="editor_body body2_2">
    	<link rel="stylesheet" type="text/css" href="/static/csshw/stylehw.css">
    <header>
        <div   id="377j5v51b"   class="head">
            <div   id="377j5v51b"   class="haed_left">
                <div   id="377j5v51b"   class="haed_logo">
                    <a href="http://m.miracleart.cn/" title="" class="haed_logo_a">
                        <img src="/static/imghw/logo.png" alt="" class="haed_logoimg">
                    </a>
                </div>
                <div   id="377j5v51b"   class="head_nav">
                    <div   id="377j5v51b"   class="head_navs">
                        <a href="javascript:;" title="Community" class="head_nava head_nava-template1">Community</a>
                        <div   class="377j5v51b"   id="dropdown-template1" style="display: none;">
                            <div   id="377j5v51b"   class="languagechoose">
                                <a href="http://m.miracleart.cn/article.html" title="Articles" class="languagechoosea on">Articles</a>
                                <a href="http://m.miracleart.cn/faq/zt" title="Topics" class="languagechoosea">Topics</a>
                                <a href="http://m.miracleart.cn/wenda.html" title="Q&A" class="languagechoosea">Q&A</a>
                            </div>
                        </div>
                    </div>
    
                    <div   id="377j5v51b"   class="head_navs">
                        <a href="javascript:;" title="Learn" class="head_nava head_nava-template1_1">Learn</a>
                        <div   class="377j5v51b"   id="dropdown-template1_1" style="display: none;">
                            <div   id="377j5v51b"   class="languagechoose">
                                <a href="http://m.miracleart.cn/course.html" title="Course" class="languagechoosea on">Course</a>
                                <a href="http://m.miracleart.cn/dic/" title="Programming Dictionary" class="languagechoosea">Programming Dictionary</a>
                            </div>
                        </div>
                    </div>
    
                    <div   id="377j5v51b"   class="head_navs">
                        <a href="javascript:;" title="Tools Library" class="head_nava head_nava-template1_2">Tools Library</a>
                        <div   class="377j5v51b"   id="dropdown-template1_2" style="display: none;">
                            <div   id="377j5v51b"   class="languagechoose">
                                <a href="http://m.miracleart.cn/toolset/development-tools" title="Development tools" class="languagechoosea on">Development tools</a>
                                <a href="http://m.miracleart.cn/toolset/website-source-code" title="Website Source Code" class="languagechoosea">Website Source Code</a>
                                <a href="http://m.miracleart.cn/toolset/php-libraries" title="PHP Libraries" class="languagechoosea">PHP Libraries</a>
                                <a href="http://m.miracleart.cn/toolset/js-special-effects" title="JS special effects" class="languagechoosea on">JS special effects</a>
                                <a href="http://m.miracleart.cn/toolset/website-materials" title="Website Materials" class="languagechoosea on">Website Materials</a>
                                <a href="http://m.miracleart.cn/toolset/extension-plug-ins" title="Extension plug-ins" class="languagechoosea on">Extension plug-ins</a>
                            </div>
                        </div>
                    </div>
    
                    <div   id="377j5v51b"   class="head_navs">
                        <a href="http://m.miracleart.cn/ai" title="AI Tools" class="head_nava head_nava-template1_3">AI Tools</a>
                    </div>
    
                    <div   id="377j5v51b"   class="head_navs">
                        <a href="javascript:;" title="Leisure" class="head_nava head_nava-template1_3">Leisure</a>
                        <div   class="377j5v51b"   id="dropdown-template1_3" style="display: none;">
                            <div   id="377j5v51b"   class="languagechoose">
                                <a href="http://m.miracleart.cn/game" title="Game Download" class="languagechoosea on">Game Download</a>
                                <a href="http://m.miracleart.cn/mobile-game-tutorial/" title="Game Tutorials" class="languagechoosea">Game Tutorials</a>
    
                            </div>
                        </div>
                    </div>
                </div>
            </div>
                        <div   id="377j5v51b"   class="head_search">
                    <input id="key_words"  onkeydown="if (event.keyCode == 13) searchs('en')" class="search-input" type="text" autocomplete="off" name="keywords" required="required" placeholder="Block,address,transaction,news" value="">
                    <a href="javascript:;" title="search"  onclick="searchs('en')"><img src="/static/imghw/find.png" alt="search"></a>
                </div>
                    <div   id="377j5v51b"   class="head_right">
                <div   id="377j5v51b"   class="haed_language">
                    <a href="javascript:;" class="layui-btn haed_language_btn">English<i class="layui-icon layui-icon-triangle-d"></i></a>
                    <div   class="377j5v51b"   id="dropdown-template" style="display: none;">
                        <div   id="377j5v51b"   class="languagechoose">
                                                    <a href="javascript:setlang('zh-cn');" title="簡體中文" class="languagechoosea">簡體中文</a>
                                                    <a href="javascript:;" title="English" class="languagechoosea">English</a>
                                                    <a href="javascript:setlang('zh-tw');" title="繁體中文" class="languagechoosea">繁體中文</a>
                                                    <a href="javascript:setlang('ja');" title="日本語" class="languagechoosea">日本語</a>
                                                    <a href="javascript:setlang('ko');" title="???" class="languagechoosea">???</a>
                                                    <a href="javascript:setlang('ms');" title="Melayu" class="languagechoosea">Melayu</a>
                                                    <a href="javascript:setlang('fr');" title="Fran?ais" class="languagechoosea">Fran?ais</a>
                                                    <a href="javascript:setlang('de');" title="Deutsch" class="languagechoosea">Deutsch</a>
                                                </div>
                    </div>
                </div>
                <span id="377j5v51b"    class="head_right_line"></span>
                                <div style="display: block;" id="login" class="haed_login ">
                        <a href="javascript:;"  title="Login" class="haed_logina ">Login</a>
                    </div>
                    <div style="display: block;" id="reg" class="head_signup login">
                        <a href="javascript:;"  title="singup" class="head_signupa">singup</a>
                    </div>
                
            </div>
        </div>
    </header>
    
    	
    	<main>
    		<div   id="377j5v51b"   class="Article_Details_main">
    			<div   id="377j5v51b"   class="Article_Details_main1">
    							<div   id="377j5v51b"   class="Article_Details_main1M">
    					<div   id="377j5v51b"   class="phpgenera_Details_mainL1">
    						<a href="http://m.miracleart.cn/" title="Home"
    							class="phpgenera_Details_mainL1a">Home</a>
    						<img src="/static/imghw/top_right.png" alt="" />
    												<a href="http://m.miracleart.cn/php-tutorials.html"
    							class="phpgenera_Details_mainL1a">php教程</a>
    						<img src="/static/imghw/top_right.png" alt="" />
    												<a href="http://m.miracleart.cn/php-ercikaifa.html"
    							class="phpgenera_Details_mainL1a">PHP開發(fā)</a>
    						<img src="/static/imghw/top_right.png" alt="" />
    						<span>Classic tutorial for getting started with Zend Framework development</span>
    					</div>
    					
    					<div   id="377j5v51b"   class="Articlelist_txts">
    						<div   id="377j5v51b"   class="Articlelist_txts_info">
    							<h1 class="Articlelist_txts_title">Classic tutorial for getting started with Zend Framework development</h1>
    							<div   id="377j5v51b"   class="Articlelist_txts_info_head">
    								<div   id="377j5v51b"   class="author_info">
    									<a href="http://m.miracleart.cn/member/13.html"  class="author_avatar">
    									<img class="lazy"  data-src="https://img.php.cn/upload/avatar/000/000/013/6177b5643d1eb119.png" src="/static/imghw/default1.png" alt="高洛峰">
    									</a>
    									<div   id="377j5v51b"   class="author_detail">
    																			<a href="http://m.miracleart.cn/member/13.html" class="author_name">高洛峰</a>
                                    										</div>
    								</div>
                    			</div>
    							<span id="377j5v51b"    class="Articlelist_txts_time">Jan 05, 2017 am	 10:08 AM</span>
    														
    						</div>
    					</div>
    					<hr />
    					<div   id="377j5v51b"   class="article_main php-article">
    						<div   id="377j5v51b"   class="article-list-left detail-content-wrap content">
    						<ins class="adsbygoogle"
    							style="display:block; text-align:center;"
    							data-ad-layout="in-article"
    							data-ad-format="fluid"
    							data-ad-client="ca-pub-5902227090019525"
    							data-ad-slot="3461856641">
    						</ins>
    						
    
    					<p>This article describes the knowledge points related to getting started with Zend Framework development. Share it with everyone for your reference, the details are as follows: </p>
    <p>Zend Framework has been released! Although still in the early stages of development, this tutorial highlights some of the best features available and guides you through building a simple program. </p>
    <p>Zend was the first to release ZF in the community. Based on the same idea, this tutorial was written to demonstrate the existing capabilities of ZF. Since this tutorial is posted online, I will update it as ZF changes so that it is as efficient as possible. </p>
    <p>Requirements</p>
    <p>Zend Framework requires PHP5. In order to make best use of the code in this tutorial, you will also need the Apache web server. Because the demonstration program (a news management system) uses mod_rewrite. </p>
    <p>The code for this tutorial is freely downloadable, so you can try it yourself. You can download the code from Brain Buld's website: http://brainbulb.com/zend-framework-tutorial.tar.gz. </p>
    <p>Download ZF</p>
    <p>When you start this tutorial, you need to download the latest version of ZF. You can use a browser to manually select the tar.gz or zip file to download from http://framework.zend.com/download, or use the following command: </p><pre class='brush:php;toolbar:false;'>$ wget http://framework.zend.com/download/tgz
    $ tar -xvzf ZendFramework-0.1.2.tar.gz</pre><p> Tip: Zend plans to provide its own PEAR channel to simplify download. </p><p>Once you download the preview version, put the library directory somewhere convenient. In this tutorial, I renamed the library to lib to have a concise directory structure: </p><p>app/<br/> views/<br/> controllers/<br/>www/<br/> .htaccess<br/> The index.php<br/>lib/</p><p>www directory is the document root directory, the controllers and views directories are empty directories that will be used later, and the lib directory comes from the preview version you downloaded. </p><p>Start</p><p>The first component I want to introduce is Zend_Controller. In many ways, it provides the foundation for the programs you develop, and it also partially determines that Zend Framework is more than just a collection of components. However, you need to put all the obtained requests into a simple PHP script before using it. This tutorial uses mod_rewrite. </p><p>Using mod_rewrite is an art in itself, but fortunately, this particular task is surprisingly easy. If you are unfamiliar with mod_rewrite or Apache configuration in general, create a .htaccess file in the document root and add the following content: </p><pre class='brush:php;toolbar:false;'>RewriteEngine on
    RewriteRule !/.(js|ico|gif|jpg|png|css)$ index.php</pre><p> </p><p></p><p> Tip: Zend_Controller One TODO item is to remove the dependency on mod_rewrite. To provide a preview of the example, this tutorial uses mod_rewrite. </p><p>If you add these contents directly to httpd.conf, you must restart the web server. But if you use a .htaccess file, you don't have to do anything. You can do a quick test by putting some specific text into index.php and accessing any path such as /foo/bar. If your domain name is example.org, visit http://example.org/foo/bar. </p><p>You also need to set the path of the ZF library to include_path. You can set it in php.ini, or you can put the following content directly in your .htaccess file: </p><pre class='brush:php;toolbar:false;'>php_value include_path "/path/to/lib"</pre><p> </p><p></p>##Zend<p></p>The Zend class contains A collection of frequently used static methods. Here is the only class you have to add manually: <p><pre class='brush:php;toolbar:false;'><?php
    include &#39;Zend.php&#39;;
    ?></pre></p> <p></p><p></p>Once you include Zend.php, you have included all the class methods of the Zend class . You can simply load other classes using loadClass(). For example, load the Zend_Controller_Front class: <p><pre class='brush:php;toolbar:false;'><?php
    include &#39;Zend.php&#39;;
    Zend::loadClass(&#39;Zend_Controller_Front&#39;);
    ?></pre></p> <p></p><p></p>include_path can understand the organization and directory structure of loadclass() and ZF. I use it to load all other classes. <p></p>Zend_Controller<p></p>Using this controller is very intuitive. In fact, I didn't use its extensive documentation when writing this tutorial. <p></p>Tips: The documentation can now be seen at http://framework.zend.com/manual/zend.controller.html. <p></p>I initially used a front controller called Zend_Controller_Front. To understand how it works, place the following code in your index.php file: <p><pre class='brush:php;toolbar:false;'><?php
    include &#39;Zend.php&#39;;
    Zend::loadClass(&#39;Zend_Controller_Front&#39;);
    $controller = Zend_Controller_Front::getInstance();
    $controller->setControllerDirectory(&#39;/path/to/controllers&#39;);
    $controller->dispatch();
    ?></pre></p> <p></p><p></p> If you prefer object links, you can use Replace the following code: <p><pre class='brush:php;toolbar:false;'><?php
    include &#39;Zend.php&#39;;
    Zend::loadClass(&#39;Zend_Controller_Front&#39;);
    $controller = Zend_Controller_Front::getInstance()
           ->setControllerDirectory(&#39;/path/to/controllers&#39;)
           ->dispatch();
    ?></pre></p> <p></p><p></p>Now if you access /foo/bar, an error will occur. That's right! It lets you know what's going on. The main problem is that the IndexController.php file cannot be found. <p></p>Before you create this file, you should first understand how the government wants you to organize these things. ZF splits the access requests. If you are accessing /foo/bar, foo is the controller and bar is the action. Their default values ??are all index.<p></p>If foo is a controller, ZF will search for the FooController.php file in the controllers directory. Because this file does not exist, ZF falls back to IndexController.php. No results were found, so an error was reported. <p></p>Next, create the IndexController.php file in the controllers directory (can be set with setControllerDirectory()): <p><pre class='brush:php;toolbar:false;'><?php
    Zend::loadClass(&#39;Zend_Controller_Action&#39;);
    class IndexController extends Zend_Controller_Action
    {
      public function indexAction()
      {
        echo &#39;IndexController::indexAction()&#39;;
      }
    }
    ?></pre></p> <p></p><p><p>就如剛才說明的,IndexController類處理來自index controller或controller不存在的請求。indexAction()方法處理action為index的訪問。要記住的是index是controller和action的默認值。如果你訪問/,/index或/index/index,indexAction()方法就會被執(zhí)行。 (最后面的斜杠并不會改變這個行為。) 而訪問其他任何資源只會導致出錯。</p><p>在繼續(xù)做之前,還要在IndexController加上另外一個有用的類方法。不管什么時候訪問一個不存在的控制器,都要調(diào)用noRouteAction()類方法。例如,在FooController.php不存在的條件下,訪問/foo/bar就會執(zhí)行noRouteAction()。但是訪問/index/foo仍會出錯,因為foo是action,而不是controller.</p><p>將noRouteAction()添加到IndexController.php:</p><pre class='brush:php;toolbar:false;'><?php
    Zend::loadClass(&#39;Zend_Controller_Action&#39;);
    class IndexController extends Zend_Controller_Action
    {
      public function indexAction()
      {
        echo &#39;IndexController::indexAction()&#39;;
      }
      public function noRouteAction()
      {
        $this->_redirect(&#39;/&#39;);
      }
    }
    ?></pre><p>   </p><p></p><p>例子中使用$this->_redirect('/')來描述執(zhí)行noRouteAction()時,可能發(fā)生的行為。這會將對不存在controllers的訪問重定向到根文檔(首頁)。</p><p>現(xiàn)在創(chuàng)建FooController.php:</p><pre class='brush:php;toolbar:false;'><?php
    Zend::loadClass(&#39;Zend_Controller_Action&#39;);
    class FooController extends Zend_Controller_Action
    {
      public function indexAction()
      {
        echo &#39;FooController::indexAction()&#39;;
      }
      public function barAction()
      {
        echo &#39;FooController::barAction()&#39;;
      }
    }
    ?></pre><p>   </p><p></p><p>如果你再次訪問/foo/bar,你會發(fā)現(xiàn)執(zhí)行了barAction(),因為bar是action?,F(xiàn)在你不只支持了友好的URL,還可以只用幾行代碼就做得這么有條理。酷吧!<br/>你也可以創(chuàng)建一個__call()類方法來處理像/foo/baz這樣未定義的action。</p><pre class='brush:php;toolbar:false;'><?php
    Zend::loadClass(&#39;Zend_Controller_Action&#39;);
    class FooController extends Zend_Controller_Action
    {
      public function indexAction()
      {
        echo &#39;FooController::indexAction()&#39;;
      }
      public function barAction()
      {
        echo &#39;FooController::barAction()&#39;;
      }
      public function __call($action, $arguments)
      {
        echo &#39;FooController:__call()&#39;;
      }
    }
    ?></pre><p>   </p><p></p><p>現(xiàn)在你只要幾行代碼就可以很好地處理用戶的訪問了,準備好繼續(xù)。</p><p>Zend_View</p><p>Zend_View是一個用來幫助你組織好你的view邏輯的類。這對于模板-系統(tǒng)是不可知的,為了簡單起見,本教程不使用模板。如果你喜歡的話,不妨用一下。</p><p>記住,現(xiàn)在所有的訪問都是由front controller進行處理。因此應(yīng)用框架已經(jīng)存在了,另外也必須遵守它。為了展示Zend_View的一個基本應(yīng)用,將IndexController.php修改如下:</p><pre class='brush:php;toolbar:false;'><?php
    Zend::loadClass(&#39;Zend_Controller_Action&#39;);
    Zend::loadClass(&#39;Zend_View&#39;);
    class IndexController extends Zend_Controller_Action
    {
      public function indexAction()
      {
        $view = new Zend_View();
        $view->setScriptPath(&#39;/path/to/views&#39;);
        echo $view->render(&#39;example.php&#39;);
      }
      public function noRouteAction()
      {
        $this->_redirect(&#39;/&#39;);
      }
    }
    ?></pre><p>   </p><p></p><p>在views目錄創(chuàng)建example.php文件:</p><pre class='brush:php;toolbar:false;'><html>
    <head>
      <title>This Is an Example</title>
    </head>
    <body>
      <p>This is an example.</p>
    </body>
    </html></pre><p>   </p><p></p><p>現(xiàn)在,如果你訪問自己網(wǎng)站的根資源,你會看到example.php的內(nèi)容。這仍沒什么用,但你要清楚你要在以一種結(jié)構(gòu)和組織非常清楚的方式在開發(fā)網(wǎng)絡(luò)應(yīng)用。</p><p>為了讓Zend_View的應(yīng)用更清楚一點,,修改你的模板(example.php)包含以下內(nèi)容:</p><pre class='brush:php;toolbar:false;'><html>
    <head>
      <title><?php echo $this->escape($this->title); ?></title>
    </head>
    <body>
      <?php echo $this->escape($this->body); ?>
    </body>
    </html></pre><p>   </p><p></p><p>現(xiàn)在已經(jīng)添加了兩個功能。$this->escape()類方法用于所有的輸出。即使你自己創(chuàng)建輸出,就像這個例子一樣。避開所有輸出也是一個很好的習慣,它可以在默認情況下幫助你防止跨站腳本攻擊(XSS)。</p><p>$this->title和$this->body屬性用來展示動態(tài)數(shù)據(jù)。這些也可以在controller中定義,所以我們修改IndexController.php以指定它們:</p><pre class='brush:php;toolbar:false;'><?php
    Zend::loadClass(&#39;Zend_Controller_Action&#39;);
    Zend::loadClass(&#39;Zend_View&#39;);
    class IndexController extends Zend_Controller_Action
    {
      public function indexAction()
      {
        $view = new Zend_View();
        $view->setScriptPath(&#39;/path/to/views&#39;);
        $view->title = &#39;Dynamic Title&#39;;
        $view->body = &#39;This is a dynamic body.&#39;;
        echo $view->render(&#39;example.php&#39;);
      }
      public function noRouteAction()
      {
        $this->_redirect(&#39;/&#39;);
      }
    }
    ?></pre><p>   </p><p></p><p>現(xiàn)在你再次訪問根目錄,應(yīng)該就可以看到模板所使用的這些值了。因為你在模板中使用的$this就是在Zend_View范圍內(nèi)所執(zhí)行的實例。</p><p>要記住example.php只是一個普通的PHP腳本,所以你完全可以做你想做的。只是應(yīng)努力只在要求顯示數(shù)據(jù)時才使用模板。你的controller (controller分發(fā)的模塊)應(yīng)處理你全部的業(yè)務(wù)邏輯。</p><p>在繼續(xù)之前,我想做最后一個關(guān)于Zend_View的提示。在controller的每個類方法內(nèi)初始化$view對象需要額外輸入一些內(nèi)容,而我們的主要目標是讓快速開發(fā)網(wǎng)絡(luò)應(yīng)用更簡單。如果所有模板都放在一個目錄下,是否要在每個例子中都調(diào)用setScriptPath()也存在爭議。</p><p>幸運的是,Zend類包含了一個寄存器來幫助減少工作量。你可以用register()方法把你的$view對象存儲在寄存器:</p><pre class='brush:php;toolbar:false;'><?php
    Zend::register(&#39;view&#39;, $view);
    ?></pre><p>   </p><p></p><p>用registry()方法進行檢索:</p><pre class='brush:php;toolbar:false;'><?php
    $view = Zend::registry(&#39;view&#39;);
    ?></pre><p>   </p><p></p><p>基于這點,本教程使用寄存器。 </p><p>Zend_InputFilter</p><p>本教程討論的最后一個組件是Zend_InputFilter。這個類提供了一種簡單而有效的輸入過濾方法。你可以通過提供一組待過濾數(shù)據(jù)來進行初始化。</p><pre class='brush:php;toolbar:false;'><?php
    $filterPost = new Zend_InputFilter($_POST);
    ?></pre><p>   </p><p></p><p>這會將($_POST)設(shè)置為NULL,所以就不能直接進入了。Zend_InputFilter提供了一個簡單、集中的根據(jù)特定規(guī)則過濾數(shù)據(jù)的類方法集。例如,你可以用getAlpha()來獲取$_POST['name']中的字母:</p><pre class='brush:php;toolbar:false;'><?php
    /* $_POST[&#39;name&#39;] = &#39;John123Doe&#39;; */
    $filterPost = new Zend_InputFilter($_POST);
    /* $_POST = NULL; */
    $alphaName = $filterPost->getAlpha(&#39;name&#39;);
    /* $alphaName = &#39;JohnDoe&#39;; */
    ?></pre><p>   </p><p></p><p>每一個類方法的參數(shù)都是對應(yīng)要過濾的元素的關(guān)鍵詞。對象(例子中的$filterPost)可以保護數(shù)據(jù)不被篡改,并能更好地控制對數(shù)據(jù)的操作及一致性。因此,當你操縱輸入數(shù)據(jù),應(yīng)始終使用Zend_InputFilter。</p><p>提示:Zend_Filter提供與Zend_InputFilter方法一樣的靜態(tài)方法。</p><p>構(gòu)建新聞管理系統(tǒng)</p><p>雖然預覽版提供了許多組件(甚至許多已經(jīng)被開發(fā)),我們已經(jīng)討論了構(gòu)建一個簡單程序所需要的全部組件。在這里,你會對ZF的基本結(jié)構(gòu)和設(shè)計有更清楚的理解。</p><p>每個人開發(fā)的程序都會有所不同,而Zend Framework試圖包容這些差異。同樣,這個教程是根據(jù)我的喜好寫的,請根據(jù)自己的偏好自行調(diào)整。</p><p>當我開發(fā)程序時,我會先做界面。這并不意味著我把時間都花在標簽、樣式表和圖片上,而是我從一個用戶的角度去考慮問題。因此我把程序看成是頁面的集合,每一頁都是一個獨立的網(wǎng)址。這個新聞系統(tǒng)就是由以下網(wǎng)址組成的:</p><p>/<br/>/add/news<br/>/add/comment<br/>/admin<br/>/admin/approve<br/>/view/{id}</p><p>你可以直接把這些網(wǎng)址和controller聯(lián)系起來。IndexController列出新聞,AddController添加新聞和評論,AdminController處理一些如批準新聞之類的管理,ViewController特定新聞和對應(yīng)評論的顯示。</p><p>如果你的FooController.php還在,把它刪除。修改IndexController.php,為業(yè)務(wù)邏輯以添加相應(yīng)的action和一些注釋:</p><pre class='brush:php;toolbar:false;'><?php
    Zend::loadClass(&#39;Zend_Controller_Action&#39;);
    class IndexController extends Zend_Controller_Action
    {
      public function indexAction()
      {
        /* List the news. */
      }
      public function noRouteAction()
      {
        $this->_redirect(&#39;/&#39;);
      }
    }
    ?></pre><p>   </p><p></p><p>接下來,創(chuàng)建AddController.php文件:</p><pre class='brush:php;toolbar:false;'><?php
    Zend::loadClass(&#39;Zend_Controller_Action&#39;);
    class AddController extends Zend_Controller_Action
    {
      function indexAction()
      {
        $this->_redirect(&#39;/&#39;);
      }
      function commentAction()
      {
        /* Add a comment. */
      }
      function newsAction()
      {
        /* Add news. */
      }
      function __call($action, $arguments)
      {
        $this->_redirect(&#39;/&#39;);
      }
    }
    ?></pre><p>   </p><p></p><p>記住AddController的indexAction()方法不能調(diào)用。當訪問/add時會執(zhí)行這個類方法。因為用戶可以手工訪問這個網(wǎng)址,這是有可能的,所以你要把用戶重定向到主頁、顯示錯誤或你認為合適的行為。</p><p>接下來,創(chuàng)建AdminController.php文件:</p><pre class='brush:php;toolbar:false;'><?php
    Zend::loadClass(&#39;Zend_Controller_Action&#39;);
    class AdminController extends Zend_Controller_Action
    {
      function indexAction()
      {
        /* Display admin interface. */
      }
      function approveAction()
      {
        /* Approve news. */
      }
      function __call($action, $arguments)
      {
        $this->_redirect(&#39;/&#39;);
      }
    }
    ?></pre><p>   </p><p></p><p>最后,創(chuàng)建ViewController.php文件:</p><pre class='brush:php;toolbar:false;'><?php
    Zend::loadClass(&#39;Zend_Controller_Action&#39;);
    class ViewController extends Zend_Controller_Action
    {
      function indexAction()
      {
        $this->_redirect(&#39;/&#39;);
      }
      function __call($id, $arguments)
      {
        /* Display news and comments for $id. */
      }
    }
    ?></pre><p>   </p><p></p><p>和AddController一樣,index()方法不能調(diào)用,所以你可以使用你認為合適的action。ViewController和其它的有點不同,因為你不知道什么才是有效的action。為了支持像/view/23這樣的網(wǎng)址,你要使用__call()來支持動態(tài)action。</p><p>數(shù)據(jù)庫操作</p><p>因為Zend Framework的數(shù)據(jù)庫組件還不穩(wěn)定,而我希望這個演示可以做得簡單一點。我使用了一個簡單的類,用SQLite進行新聞條目和評論的存儲和查詢。</p><pre class='brush:php;toolbar:false;'><?php
    class Database
    {
      private $_db;
      public function __construct($filename)
      {
        $this->_db = new SQLiteDatabase($filename);
      }
      public function addComment($name, $comment, $newsId)
      {
        $name = sqlite_escape_string($name);
        $comment = sqlite_escape_string($comment);
        $newsId = sqlite_escape_string($newsId);
        $sql = "INSERT
            INTO  comments (name, comment, newsId)
            VALUES (&#39;$name&#39;, &#39;$comment&#39;, &#39;$newsId&#39;)";
        return $this->_db->query($sql);
      }
      public function addNews($title, $content)
      {
        $title = sqlite_escape_string($title);
        $content = sqlite_escape_string($content);
        $sql = "INSERT
            INTO  news (title, content)
            VALUES (&#39;$title&#39;, &#39;$content&#39;)";
        return $this->_db->query($sql);
      }
      public function approveNews($ids)
      {
        foreach ($ids as $id) {
          $id = sqlite_escape_string($id);
          $sql = "UPDATE news
              SET  approval = &#39;T&#39;
              WHERE id = &#39;$id&#39;";
          if (!$this->_db->query($sql)) {
            return FALSE;
          }
        }
        return TRUE;
      }
      public function getComments($newsId)
      {
        $newsId = sqlite_escape_string($newsId);
        $sql = "SELECT name, comment
            FROM  comments
            WHERE newsId = &#39;$newsId&#39;";
        if ($result = $this->_db->query($sql)) {
          return $result->fetchAll();
        }
        return FALSE;
      }
      public function getNews($id = &#39;ALL&#39;)
      {
        $id = sqlite_escape_string($id);
        switch ($id) {
          case &#39;ALL&#39;:
            $sql = "SELECT id,
                    title
                FROM  news
                WHERE approval = &#39;T&#39;";
            break;
          case &#39;NEW&#39;:
            $sql = "SELECT *
                FROM  news
                WHERE approval != &#39;T&#39;";
            break;
          default:
            $sql = "SELECT *
                FROM  news
                WHERE id = &#39;$id&#39;";
            break;
        }
        if ($result = $this->_db->query($sql)) {
          if ($result->numRows() != 1) {
            return $result->fetchAll();
          } else {
            return $result->fetch();
          }
        }
        return FALSE;
      }
    }
    ?></pre><p>   </p><p></p><p>(你可以用自己的解決方案隨意替換這個類。這里只是為你提供一個完整示例的介紹,并非建議要這么實現(xiàn)。)</p><p>這個類的構(gòu)造器需要SQLite數(shù)據(jù)庫的完整路徑和文件名,你必須自己進行創(chuàng)建。</p><pre class='brush:php;toolbar:false;'><?php
    $db = new SQLiteDatabase(&#39;/path/to/db.sqlite&#39;);
    $db->query("CREATE TABLE news (
        id    INTEGER PRIMARY KEY,
        title  VARCHAR(255),
        content TEXT,
        approval CHAR(1) DEFAULT &#39;F&#39;
      )");
    $db->query("CREATE TABLE comments (
        id    INTEGER PRIMARY KEY,
        name   VARCHAR(255),
        comment TEXT,
        newsId  INTEGER
      )");
    ?></pre><p>   </p><p></p><p>你只需要做一次,以后直接給出Database類構(gòu)造器的完整路徑和文件名即可:</p><pre class='brush:php;toolbar:false;'><?php
    $db = new Database(&#39;/path/to/db.sqlite&#39;);
    ?></pre><p>   </p><p></p><p>整合</p><p>為了進行整合,在lib目錄下創(chuàng)建Database.php,loadClass()就可以找到它。你的index.php文件現(xiàn)在就會初始化$view和$db并存儲到寄存器。你也可以創(chuàng)建__autoload()函數(shù)自動加載你所需要的類:</p><pre class='brush:php;toolbar:false;'><?php
    include &#39;Zend.php&#39;;
    function __autoload($class)
    {
      Zend::loadClass($class);
    }
    $db = new Database(&#39;/path/to/db.sqlite&#39;);
    Zend::register(&#39;db&#39;, $db);
    $view = new Zend_View;
    $view->setScriptPath(&#39;/path/to/views&#39;);
    Zend::register(&#39;view&#39;, $view);
    $controller = Zend_Controller_Front::getInstance()
           ->setControllerDirectory(&#39;/path/to/controllers&#39;)
           ->dispatch();
    ?></pre><p>   </p><p></p><p>接下來,在views目錄創(chuàng)建一些簡單的模板。index.php可以用來顯示index視圖:</p><pre class='brush:php;toolbar:false;'><html>
    <head>
     <title>News</title>
    </head>
    <body>
     <h1>News</h1>
     <?php foreach ($this->news as $entry) { ?>
     <p>
      <a href="/view/<?php echo $this->escape($entry[&#39;id&#39;]); ?>">
      <?php echo $this->escape($entry[&#39;title&#39;]); ?>
      </a>
     </p>
     <?php } ?>
     <h1>Add News</h1>
     <form action="/add/news" method="POST">
     <p>Title:<br /><input type="text" name="title" /></p>
     <p>Content:<br /><textarea name="content"></textarea></p>
     <p><input type="submit" value="Add News" /></p>
     </form>
    </body>
    </html></pre><p>   </p><p></p><p>view.php模板可以用來顯示選定的新聞條目:</p><pre class='brush:php;toolbar:false;'><html>
    <head>
     <title>
      <?php echo $this->escape($this->news[&#39;title&#39;]); ?>
     </title>
    </head>
    <body>
     <h1>
      <?php echo $this->escape($this->news[&#39;title&#39;]); ?>
     </h1>
     <p>
      <?php echo $this->escape($this->news[&#39;content&#39;]); ?>
     </p>
     <h1>Comments</h1>
     <?php foreach ($this->comments as $comment) { ?>
     <p>
      <?php echo $this->escape($comment[&#39;name&#39;]); ?> writes:
     </p>
     <blockquote>
      <?php echo $this->escape($comment[&#39;comment&#39;]); ?>
     </blockquote>
     <?php } ?>
     <h1>Add a Comment</h1>
     <form action="/add/comment" method="POST">
     <input type="hidden" name="newsId"
      value="<?php echo $this->escape($this->id); ?>" />
     <p>Name:<br /><input type="text" name="name" /></p>
     <p>Comment:<br /><textarea name="comment"></textarea></p>
     <p><input type="submit" value="Add Comment" /></p>
     </form>
    </body>
    </html></pre><p>   </p><p></p><p>最后,admin.php模板可以用來批準新聞條目:</p><pre class='brush:php;toolbar:false;'><html>
    <head>
     <title>News Admin</title>
    </head>
    <body>
     <form action="/admin/approve" method="POST">
     <?php foreach ($this->news as $entry) { ?>
     <p>
      <input type="checkbox" name="ids[]"
      value="<?php echo $this->escape($entry[&#39;id&#39;]); ?>" />
      <?php echo $this->escape($entry[&#39;title&#39;]); ?>
      <?php echo $this->escape($entry[&#39;content&#39;]); ?>
     </p>
     <?php } ?>
     <p>
      Password:<br /><input type="password" name="password" />
     </p>
     <p><input type="submit" value="Approve" /></p>
     </form>
    </body>
    </html></pre><p>   </p><p></p><p>提示:為了保持簡單,這個表單用密碼作為驗證機制。</p><p>使用到模板的地方,你只需要把注釋替換成幾行代碼。如IndexController.php就變成下面這樣:</p><pre class='brush:php;toolbar:false;'><?php
    class IndexController extends Zend_Controller_Action
    {
      public function indexAction()
      {
        /* List the news. */
        $db = Zend::registry(&#39;db&#39;);
        $view = Zend::registry(&#39;view&#39;);
        $view->news = $db->getNews();
        echo $view->render(&#39;index.php&#39;);
      }
      public function noRouteAction()
      {
        $this->_redirect(&#39;/&#39;);
      }
    }
    ?></pre><p>   </p><p></p><p>因為條理比較清楚,這個程序首頁的整個業(yè)務(wù)邏輯只有四行代碼。AddController.php更復雜一點,它需要更多的代碼:</p><pre class='brush:php;toolbar:false;'><?php
    class AddController extends Zend_Controller_Action
    {
      function indexAction()
      {
        $this->_redirect(&#39;/&#39;);
      }
      function commentAction()
      {
        /* Add a comment. */
        $filterPost = new Zend_InputFilter($_POST);
        $db = Zend::registry(&#39;db&#39;);
        $name = $filterPost->getAlpha(&#39;name&#39;);
        $comment = $filterPost->noTags(&#39;comment&#39;);
        $newsId = $filterPost->getDigits(&#39;newsId&#39;);
        $db->addComment($name, $comment, $newsId);
        $this->_redirect("/view/$newsId");
      }
      function newsAction()
      {
        /* Add news. */
        $filterPost = new Zend_InputFilter($_POST);
        $db = Zend::registry(&#39;db&#39;);
        $title = $filterPost->noTags(&#39;title&#39;);
        $content = $filterPost->noTags(&#39;content&#39;);
        $db->addNews($title, $content);
        $this->_redirect(&#39;/&#39;);
      }
      function __call($action, $arguments)
      {
        $this->_redirect(&#39;/&#39;);
      }
    }
    ?></pre><p>   </p><p></p><p>因為用戶在提交表單后被重定向,這個controller不需要視圖。</p><p>在AdminController.php,你要處理顯示管理界面和批準新聞兩個action:</p><pre class='brush:php;toolbar:false;'><?php
    class AdminController extends Zend_Controller_Action
    {
      function indexAction()
      {
        /* Display admin interface. */
        $db = Zend::registry(&#39;db&#39;);
        $view = Zend::registry(&#39;view&#39;);
        $view->news = $db->getNews(&#39;NEW&#39;);
        echo $view->render(&#39;admin.php&#39;);
      }
      function approveAction()
      {
        /* Approve news. */
        $filterPost = new Zend_InputFilter($_POST);
        $db = Zend::registry(&#39;db&#39;);
        if ($filterPost->getRaw(&#39;password&#39;) == &#39;mypass&#39;) {
          $db->approveNews($filterPost->getRaw(&#39;ids&#39;));
          $this->_redirect(&#39;/&#39;);
        } else {
          echo &#39;The password is incorrect.&#39;;
        }
      }
      function __call($action, $arguments)
      {
        $this->_redirect(&#39;/&#39;);
      }
    }
    ?></pre><p>   </p><p></p><p>最后是ViewController.php:</p><pre class='brush:php;toolbar:false;'><?php
    class ViewController extends Zend_Controller_Action
    {
      function indexAction()
      {
        $this->_redirect(&#39;/&#39;);
      }
      function __call($id, $arguments)
      {
        /* Display news and comments for $id. */
        $id = Zend_Filter::getDigits($id);
        $db = Zend::registry(&#39;db&#39;);
        $view = Zend::registry(&#39;view&#39;);
        $view->news = $db->getNews($id);
        $view->comments = $db->getComments($id);
        $view->id = $id;
        echo $view->render(&#39;view.php&#39;);
      }
    }
    ?></pre><p>? ?</p>
    <p></p>
    <p>雖然很簡單,但我們還是提供了一個功能較全的新聞和評論程序。最好的地方是由于有較好的設(shè)計,增加功能變得很簡單。而且隨著Zend Framework越來越成熟,只會變得更好。</p>
    <p>更多信息</p>
    <p>這個教程只是討論了ZF表面的一些功能,但現(xiàn)在也有一些其它的資源可供參考。在http://framework.zend.com/manual/有手冊可以查詢,Rob Allen在http://akrabat.com/zend-framework/介紹了一些他使用Zend Framework的經(jīng)驗,而Richard Thomas也在http://www.cyberlot.net/zendframenotes提供了一些有用的筆記。如果你有自己的想法,可以訪問Zend Framework的新論壇:http://www.phparch.com/discuss/index.php/f/289//。</p>
    <p>結(jié)束語</p>
    <p>要對預覽版進行評價是很容易的事,我在寫這個教程時也遇到很多困難??偟膩碚f,我想Zend Framework顯示了承諾,加入的每個人都是想繼續(xù)完善它。</p>
    <p>I hope this article will be helpful to everyone’s PHP programming based on the Zend Framework framework. </p>
    <p>For more articles related to Zend Framework development introductory classic tutorials, please pay attention to the PHP Chinese website! </p>
    
    
    						</div>
    					</div>
    					<div   id="377j5v51b"   class="wzconShengming_sp">
    						<div   id="377j5v51b"   class="bzsmdiv_sp">Statement of this Website</div>
    						<div>The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn</div>
    					</div>
    				</div>
    
    				<ins class="adsbygoogle"
         style="display:block"
         data-ad-format="autorelaxed"
         data-ad-client="ca-pub-5902227090019525"
         data-ad-slot="2507867629"></ins>
    
    
    
    				<div   id="377j5v51b"   class="AI_ToolDetails_main4sR">
    
    
    				<ins class="adsbygoogle"
            style="display:block"
            data-ad-client="ca-pub-5902227090019525"
            data-ad-slot="3653428331"
            data-ad-format="auto"
            data-full-width-responsive="true"></ins>
        
    
    
    					<!-- <div   id="377j5v51b"   class="phpgenera_Details_mainR4">
    						<div   id="377j5v51b"   class="phpmain1_4R_readrank">
    							<div   id="377j5v51b"   class="phpmain1_4R_readrank_top">
    								<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    									onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    									src="/static/imghw/hotarticle2.png" alt="" />
    								<h2>Hot Article</h2>
    							</div>
    							<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottom">
    															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
    									<a href="http://m.miracleart.cn/faq/1796821119.html" title="Guide: Stellar Blade Save File Location/Save File Lost/Not Saving" class="phpgenera_Details_mainR4_bottom_title">Guide: Stellar Blade Save File Location/Save File Lost/Not Saving</a>
    									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
    										<span>4 weeks ago</span>
    										<span>By DDD</span>
    									</div>
    								</div>
    															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
    									<a href="http://m.miracleart.cn/faq/1796827210.html" title="Oguri Cap Build Guide | A Pretty Derby Musume" class="phpgenera_Details_mainR4_bottom_title">Oguri Cap Build Guide | A Pretty Derby Musume</a>
    									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
    										<span>2 weeks ago</span>
    										<span>By Jack chen</span>
    									</div>
    								</div>
    															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
    									<a href="http://m.miracleart.cn/faq/1796828723.html" title="Agnes Tachyon Build Guide | A Pretty Derby Musume" class="phpgenera_Details_mainR4_bottom_title">Agnes Tachyon Build Guide | A Pretty Derby Musume</a>
    									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
    										<span>1 weeks ago</span>
    										<span>By Jack chen</span>
    									</div>
    								</div>
    															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
    									<a href="http://m.miracleart.cn/faq/1796821436.html" title="Dune: Awakening - Advanced Planetologist Quest Walkthrough" class="phpgenera_Details_mainR4_bottom_title">Dune: Awakening - Advanced Planetologist Quest Walkthrough</a>
    									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
    										<span>3 weeks ago</span>
    										<span>By Jack chen</span>
    									</div>
    								</div>
    															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
    									<a href="http://m.miracleart.cn/faq/1796821278.html" title="Date Everything: Dirk And Harper Relationship Guide" class="phpgenera_Details_mainR4_bottom_title">Date Everything: Dirk And Harper Relationship Guide</a>
    									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
    										<span>4 weeks ago</span>
    										<span>By Jack chen</span>
    									</div>
    								</div>
    														</div>
    							<div   id="377j5v51b"   class="phpgenera_Details_mainR3_more">
    								<a href="http://m.miracleart.cn/article.html">Show More</a>
    							</div>
    						</div>
    					</div> -->
    
    
    											<div   id="377j5v51b"   class="phpgenera_Details_mainR3">
    							<div   id="377j5v51b"   class="phpmain1_4R_readrank">
    								<div   id="377j5v51b"   class="phpmain1_4R_readrank_top">
    									<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    										onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    										src="/static/imghw/hottools2.png" alt="" />
    									<h2>Hot AI Tools</h2>
    								</div>
    								<div   id="377j5v51b"   class="phpgenera_Details_mainR3_bottom">
    																		<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
    											<a href="http://m.miracleart.cn/ai/undress-ai-tool" title="Undress AI Tool" class="phpmain_tab2_mids_top_img">
    												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													class="lazy"  data-src="https://img.php.cn/upload/ai_manual/001/246/273/173410641626608.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Undress AI Tool" />
    											</a>
    											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
    												<a href="http://m.miracleart.cn/ai/undress-ai-tool" title="Undress AI Tool" class="phpmain_tab2_mids_title">
    													<h3>Undress AI Tool</h3>
    												</a>
    												<p>Undress images for free</p>
    											</div>
    										</div>
    																		<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
    											<a href="http://m.miracleart.cn/ai/undresserai-undress" title="Undresser.AI Undress" class="phpmain_tab2_mids_top_img">
    												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													class="lazy"  data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411540686492.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Undresser.AI Undress" />
    											</a>
    											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
    												<a href="http://m.miracleart.cn/ai/undresserai-undress" title="Undresser.AI Undress" class="phpmain_tab2_mids_title">
    													<h3>Undresser.AI Undress</h3>
    												</a>
    												<p>AI-powered app for creating realistic nude photos</p>
    											</div>
    										</div>
    																		<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
    											<a href="http://m.miracleart.cn/ai/ai-clothes-remover" title="AI Clothes Remover" class="phpmain_tab2_mids_top_img">
    												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													class="lazy"  data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411552797167.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="AI Clothes Remover" />
    											</a>
    											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
    												<a href="http://m.miracleart.cn/ai/ai-clothes-remover" title="AI Clothes Remover" class="phpmain_tab2_mids_title">
    													<h3>AI Clothes Remover</h3>
    												</a>
    												<p>Online AI tool for removing clothes from photos.</p>
    											</div>
    										</div>
    																		<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
    											<a href="http://m.miracleart.cn/ai/clothoffio" title="Clothoff.io" class="phpmain_tab2_mids_top_img">
    												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													class="lazy"  data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411529149311.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Clothoff.io" />
    											</a>
    											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
    												<a href="http://m.miracleart.cn/ai/clothoffio" title="Clothoff.io" class="phpmain_tab2_mids_title">
    													<h3>Clothoff.io</h3>
    												</a>
    												<p>AI clothes remover</p>
    											</div>
    										</div>
    																		<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
    											<a href="http://m.miracleart.cn/ai/video-swap" title="Video Face Swap" class="phpmain_tab2_mids_top_img">
    												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													class="lazy"  data-src="https://img.php.cn/upload/ai_manual/001/246/273/173414504068133.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Video Face Swap" />
    											</a>
    											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
    												<a href="http://m.miracleart.cn/ai/video-swap" title="Video Face Swap" class="phpmain_tab2_mids_title">
    													<h3>Video Face Swap</h3>
    												</a>
    												<p>Swap faces in any video effortlessly with our completely free AI face swap tool!</p>
    											</div>
    										</div>
    																</div>
    								<div   id="377j5v51b"   class="phpgenera_Details_mainR3_more">
    									<a href="http://m.miracleart.cn/ai">Show More</a>
    								</div>
    							</div>
    						</div>
    					
    
    
    					<div   id="377j5v51b"   class="phpgenera_Details_mainR4">
    						<div   id="377j5v51b"   class="phpmain1_4R_readrank">
    							<div   id="377j5v51b"   class="phpmain1_4R_readrank_top">
    								<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    									onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    									src="/static/imghw/hotarticle2.png" alt="" />
    								<h2>Hot Article</h2>
    							</div>
    							<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottom">
    															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
    									<a href="http://m.miracleart.cn/faq/1796821119.html" title="Guide: Stellar Blade Save File Location/Save File Lost/Not Saving" class="phpgenera_Details_mainR4_bottom_title">Guide: Stellar Blade Save File Location/Save File Lost/Not Saving</a>
    									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
    										<span>4 weeks ago</span>
    										<span>By DDD</span>
    									</div>
    								</div>
    															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
    									<a href="http://m.miracleart.cn/faq/1796827210.html" title="Oguri Cap Build Guide | A Pretty Derby Musume" class="phpgenera_Details_mainR4_bottom_title">Oguri Cap Build Guide | A Pretty Derby Musume</a>
    									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
    										<span>2 weeks ago</span>
    										<span>By Jack chen</span>
    									</div>
    								</div>
    															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
    									<a href="http://m.miracleart.cn/faq/1796828723.html" title="Agnes Tachyon Build Guide | A Pretty Derby Musume" class="phpgenera_Details_mainR4_bottom_title">Agnes Tachyon Build Guide | A Pretty Derby Musume</a>
    									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
    										<span>1 weeks ago</span>
    										<span>By Jack chen</span>
    									</div>
    								</div>
    															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
    									<a href="http://m.miracleart.cn/faq/1796821436.html" title="Dune: Awakening - Advanced Planetologist Quest Walkthrough" class="phpgenera_Details_mainR4_bottom_title">Dune: Awakening - Advanced Planetologist Quest Walkthrough</a>
    									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
    										<span>3 weeks ago</span>
    										<span>By Jack chen</span>
    									</div>
    								</div>
    															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
    									<a href="http://m.miracleart.cn/faq/1796821278.html" title="Date Everything: Dirk And Harper Relationship Guide" class="phpgenera_Details_mainR4_bottom_title">Date Everything: Dirk And Harper Relationship Guide</a>
    									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
    										<span>4 weeks ago</span>
    										<span>By Jack chen</span>
    									</div>
    								</div>
    														</div>
    							<div   id="377j5v51b"   class="phpgenera_Details_mainR3_more">
    								<a href="http://m.miracleart.cn/article.html">Show More</a>
    							</div>
    						</div>
    					</div>
    
    
    											<div   id="377j5v51b"   class="phpgenera_Details_mainR3">
    							<div   id="377j5v51b"   class="phpmain1_4R_readrank">
    								<div   id="377j5v51b"   class="phpmain1_4R_readrank_top">
    									<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    										onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    										src="/static/imghw/hottools2.png" alt="" />
    									<h2>Hot Tools</h2>
    								</div>
    								<div   id="377j5v51b"   class="phpgenera_Details_mainR3_bottom">
    																		<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
    											<a href="http://m.miracleart.cn/toolset/development-tools/92" title="Notepad++7.3.1" class="phpmain_tab2_mids_top_img">
    												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													class="lazy"  data-src="https://img.php.cn/upload/manual/000/000/001/58ab96f0f39f7357.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="Notepad++7.3.1" />
    											</a>
    											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
    												<a href="http://m.miracleart.cn/toolset/development-tools/92" title="Notepad++7.3.1" class="phpmain_tab2_mids_title">
    													<h3>Notepad++7.3.1</h3>
    												</a>
    												<p>Easy-to-use and free code editor</p>
    											</div>
    										</div>
    																			<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
    											<a href="http://m.miracleart.cn/toolset/development-tools/93" title="SublimeText3 Chinese version" class="phpmain_tab2_mids_top_img">
    												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													class="lazy"  data-src="https://img.php.cn/upload/manual/000/000/001/58ab97a3baad9677.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="SublimeText3 Chinese version" />
    											</a>
    											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
    												<a href="http://m.miracleart.cn/toolset/development-tools/93" title="SublimeText3 Chinese version" class="phpmain_tab2_mids_title">
    													<h3>SublimeText3 Chinese version</h3>
    												</a>
    												<p>Chinese version, very easy to use</p>
    											</div>
    										</div>
    																			<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
    											<a href="http://m.miracleart.cn/toolset/development-tools/121" title="Zend Studio 13.0.1" class="phpmain_tab2_mids_top_img">
    												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													class="lazy"  data-src="https://img.php.cn/upload/manual/000/000/001/58ab97ecd1ab2670.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="Zend Studio 13.0.1" />
    											</a>
    											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
    												<a href="http://m.miracleart.cn/toolset/development-tools/121" title="Zend Studio 13.0.1" class="phpmain_tab2_mids_title">
    													<h3>Zend Studio 13.0.1</h3>
    												</a>
    												<p>Powerful PHP integrated development environment</p>
    											</div>
    										</div>
    																			<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
    											<a href="http://m.miracleart.cn/toolset/development-tools/469" title="Dreamweaver CS6" class="phpmain_tab2_mids_top_img">
    												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													class="lazy"  data-src="https://img.php.cn/upload/manual/000/000/001/58d0e0fc74683535.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="Dreamweaver CS6" />
    											</a>
    											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
    												<a href="http://m.miracleart.cn/toolset/development-tools/469" title="Dreamweaver CS6" class="phpmain_tab2_mids_title">
    													<h3>Dreamweaver CS6</h3>
    												</a>
    												<p>Visual web development tools</p>
    											</div>
    										</div>
    																			<div   id="377j5v51b"   class="phpmain_tab2_mids_top">
    											<a href="http://m.miracleart.cn/toolset/development-tools/500" title="SublimeText3 Mac version" class="phpmain_tab2_mids_top_img">
    												<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    													class="lazy"  data-src="https://img.php.cn/upload/manual/000/000/001/58d34035e2757995.png?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="SublimeText3 Mac version" />
    											</a>
    											<div   id="377j5v51b"   class="phpmain_tab2_mids_info">
    												<a href="http://m.miracleart.cn/toolset/development-tools/500" title="SublimeText3 Mac version" class="phpmain_tab2_mids_title">
    													<h3>SublimeText3 Mac version</h3>
    												</a>
    												<p>God-level code editing software (SublimeText3)</p>
    											</div>
    										</div>
    																	</div>
    								<div   id="377j5v51b"   class="phpgenera_Details_mainR3_more">
    									<a href="http://m.miracleart.cn/ai">Show More</a>
    								</div>
    							</div>
    						</div>
    										
    
    					
    					<div   id="377j5v51b"   class="phpgenera_Details_mainR4">
    						<div   id="377j5v51b"   class="phpmain1_4R_readrank">
    							<div   id="377j5v51b"   class="phpmain1_4R_readrank_top">
    								<img onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    									onerror="this.onerror=''; this.src='/static/imghw/default1.png'"
    									src="/static/imghw/hotarticle2.png" alt="" />
    								<h2>Hot Topics</h2>
    							</div>
    							<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottom">
    															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
    									<a href="http://m.miracleart.cn/faq/gmailyxdlrkzn" title="Where is the login entrance for gmail email?" class="phpgenera_Details_mainR4_bottom_title">Where is the login entrance for gmail email?</a>
    									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
    										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
    											<img src="/static/imghw/eyess.png" alt="" />
    											<span>8637</span>
    										</div>
    										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
    											<img src="/static/imghw/tiezi.png" alt="" />
    											<span>17</span>
    										</div>
    									</div>
    								</div>
    															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
    									<a href="http://m.miracleart.cn/faq/java-tutorial" title="Java Tutorial" class="phpgenera_Details_mainR4_bottom_title">Java Tutorial</a>
    									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
    										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
    											<img src="/static/imghw/eyess.png" alt="" />
    											<span>1783</span>
    										</div>
    										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
    											<img src="/static/imghw/tiezi.png" alt="" />
    											<span>16</span>
    										</div>
    									</div>
    								</div>
    															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
    									<a href="http://m.miracleart.cn/faq/cakephp-tutor" title="CakePHP Tutorial" class="phpgenera_Details_mainR4_bottom_title">CakePHP Tutorial</a>
    									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
    										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
    											<img src="/static/imghw/eyess.png" alt="" />
    											<span>1727</span>
    										</div>
    										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
    											<img src="/static/imghw/tiezi.png" alt="" />
    											<span>56</span>
    										</div>
    									</div>
    								</div>
    															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
    									<a href="http://m.miracleart.cn/faq/laravel-tutori" title="Laravel Tutorial" class="phpgenera_Details_mainR4_bottom_title">Laravel Tutorial</a>
    									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
    										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
    											<img src="/static/imghw/eyess.png" alt="" />
    											<span>1577</span>
    										</div>
    										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
    											<img src="/static/imghw/tiezi.png" alt="" />
    											<span>28</span>
    										</div>
    									</div>
    								</div>
    															<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms">
    									<a href="http://m.miracleart.cn/faq/php-tutorial" title="PHP Tutorial" class="phpgenera_Details_mainR4_bottom_title">PHP Tutorial</a>
    									<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_info">
    										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
    											<img src="/static/imghw/eyess.png" alt="" />
    											<span>1442</span>
    										</div>
    										<div   id="377j5v51b"   class="phpgenera_Details_mainR4_bottoms_infos">
    											<img src="/static/imghw/tiezi.png" alt="" />
    											<span>31</span>
    										</div>
    									</div>
    								</div>
    														</div>
    							<div   id="377j5v51b"   class="phpgenera_Details_mainR3_more">
    								<a href="http://m.miracleart.cn/faq/zt">Show More</a>
    							</div>
    						</div>
    					</div>
    				</div>
    			</div>
    					</div>
    	</main>
    	<footer>
        <div   id="377j5v51b"   class="footer">
            <div   id="377j5v51b"   class="footertop">
                <img src="/static/imghw/logo.png" alt="">
                <p>Public welfare online PHP training,Help PHP learners grow quickly!</p>
            </div>
            <div   id="377j5v51b"   class="footermid">
                <a href="http://m.miracleart.cn/about/us.html">About us</a>
                <a href="http://m.miracleart.cn/about/disclaimer.html">Disclaimer</a>
                <a href="http://m.miracleart.cn/update/article_0_1.html">Sitemap</a>
            </div>
            <div   id="377j5v51b"   class="footerbottom">
                <p>
                    ? php.cn All rights reserved
                </p>
            </div>
        </div>
    </footer>
    
    <input type="hidden" id="verifycode" value="/captcha.html">
    
    
    
    
    		<link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css?2' type='text/css' media='all' />
    	
    	
    	
    	
    	
    
    	
    	
    
    
    
    
    
    
    <footer>
    <div class="friendship-link">
    <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p>
    <a href="http://m.miracleart.cn/" title="国产av日韩一区二区三区精品">国产av日韩一区二区三区精品</a>
    
    <div class="friend-links">
    
    
    </div>
    </div>
    
    </footer>
    
    
    <script>
    (function(){
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        }
        else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
    </script>
    </body><div id="epamh" class="pl_css_ganrao" style="display: none;"><thead id="epamh"><acronym id="epamh"><pre id="epamh"><rp id="epamh"></rp></pre></acronym></thead><style id="epamh"><menu id="epamh"><label id="epamh"><th id="epamh"></th></label></menu></style><output id="epamh"><abbr id="epamh"><li id="epamh"></li></abbr></output><strike id="epamh"><strike id="epamh"><wbr id="epamh"></wbr></strike></strike><big id="epamh"><center id="epamh"></center></big><em id="epamh"><button id="epamh"><samp id="epamh"></samp></button></em><video id="epamh"></video><sub id="epamh"></sub><input id="epamh"></input><strike id="epamh"><progress id="epamh"><td id="epamh"><samp id="epamh"></samp></td></progress></strike><abbr id="epamh"><b id="epamh"><em id="epamh"></em></b></abbr><object id="epamh"><label id="epamh"><pre id="epamh"><thead id="epamh"></thead></pre></label></object><em id="epamh"><tt id="epamh"><option id="epamh"><track id="epamh"></track></option></tt></em><dl id="epamh"><legend id="epamh"><rt id="epamh"><dl id="epamh"></dl></rt></legend></dl><tt id="epamh"><option id="epamh"></option></tt><dd id="epamh"></dd><form id="epamh"></form><s id="epamh"><strong id="epamh"><dl id="epamh"></dl></strong></s><ruby id="epamh"><li id="epamh"></li></ruby><object id="epamh"></object><small id="epamh"><noframes id="epamh"></noframes></small><tbody id="epamh"><optgroup id="epamh"><nav id="epamh"><strong id="epamh"></strong></nav></optgroup></tbody><i id="epamh"><source id="epamh"></source></i><samp id="epamh"></samp><meter id="epamh"><sub id="epamh"><b id="epamh"></b></sub></meter><dd id="epamh"><tr id="epamh"><dfn id="epamh"><blockquote id="epamh"></blockquote></dfn></tr></dd><center id="epamh"><thead id="epamh"></thead></center><track id="epamh"></track><sub id="epamh"></sub><option id="epamh"></option><label id="epamh"></label><meter id="epamh"></meter><tt id="epamh"><option id="epamh"></option></tt><blockquote id="epamh"><font id="epamh"></font></blockquote><form id="epamh"></form><legend id="epamh"></legend><legend id="epamh"><pre id="epamh"><blockquote id="epamh"></blockquote></pre></legend><div id="epamh"></div><dfn id="epamh"><abbr id="epamh"></abbr></dfn><pre id="epamh"></pre><sup id="epamh"><ol id="epamh"><th id="epamh"><strike id="epamh"></strike></th></ol></sup><pre id="epamh"><pre id="epamh"><s id="epamh"><rt id="epamh"></rt></s></pre></pre><center id="epamh"><dd id="epamh"><font id="epamh"><em id="epamh"></em></font></dd></center><mark id="epamh"><kbd id="epamh"><tbody id="epamh"></tbody></kbd></mark><mark id="epamh"></mark><noframes id="epamh"></noframes><del id="epamh"><ul id="epamh"><u id="epamh"><table id="epamh"></table></u></ul></del><ol id="epamh"></ol><progress id="epamh"></progress><optgroup id="epamh"><th id="epamh"></th></optgroup></div>
    
    </html>