<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                為了使所有的模板文件能夠看起來足夠簡潔和便于理解,在模板文件的編寫上將盡量的用少的代碼及多的常用代碼來進行講解,而且在模板文件中較多的代碼仍為普通的HTML代碼;所以在下面涉及到的 css 文件和 js 文件都是以空文件的形式來引用,使用空文件的原因主要是為說明相關函數的功能特性,同時對模板文件進行解釋的主要內容也在ZF2的函數上。 ### 5.3.1 模板文件layout.phtml 下面是代碼內容: ~~~ <?php echo $this->doctype(); ?> <html> <head> <meta charset="utf-8"> <?php echo $this->headTitle($this->translate('doc title')); ?> <?php echo $this->headMeta()->appendName('viewport', 'width=device-width, initial-scale=1.0'); ?> <?php echo $this->headLink()->prependStylesheet($this->basePath() . '/css/style.css'); ?> <?php echo $this->headScript()->prependFile($this->basePath() . '/js/jquery.min.js'', 'text/javascript');?> </head> <body> <table border="1" cellspacing="0" cellspadding="0" width="100%"> <tr> <td>header</td> </tr> <tr><td><?php echo $this->content; ?></td></tr> <tr><td>footer</td></tr> </table> </body> </html> ~~~ 模板內容解釋: echo $this->doctype() 文檔使用的類型,這個類型與在模塊配置文件中設置的類型有關 echo $this->headTitle(); 輸出文檔標題 $this->translate('doc title') 轉換文檔標題,此函數功能的實現需要語言包的支持 echo $this->headMeta() 輸出HTML人 Meta 屬性 appendName('viewport', 'width=device-width, initial-scale=1.0') 設置Meta 屬性的具體內容 echo $this->headLink() 輸出link標簽 prependStylesheet($this->basePath() . '/css/style.css') 設置link標簽屬性 $this->basePath() 獲取站點根路徑 echo $this->headScript() 輸出 script 標簽 prependFile($this->basePath() . '/js/jquery.min.js'', 'text/javascript') 設置 script 標簽屬性 echo $this->content 輸出控制器對應的模板頁面內容 以上的內容就是一個簡單的layout 而已模板,沒有復雜的代碼,沒有復雜的樣式;布局的結構最后將呈現出 上-中-下 的三行結構;上部放置導航內容,中部放置頁面主要內容,下部放置版權信息等。所以最終看到的界面大概如下所示: header 頭部內容 content 正文內容 footer 底部內容 ### 5.3.2 錯誤異常模板 index.phtml 下面是代碼內容: ~~~ <h1><?php echo $this->translate('An error occurred') ?></h1> <h2><?php echo $this->message ?></h2> <?php if (isset($this->display_exceptions) && $this->display_exceptions): ?> <?php if(isset($this->exception) && $this->exception instanceof Exception): ?> <hr/> <h2><?php echo $this->translate('Additional information') ?>:</h2> <h3><?php echo get_class($this->exception); ?></h3> <dl> <dt><?php echo $this->translate('File') ?>:</dt> <dd> <pre class="prettyprint linenums"><?php echo $this->exception->getFile() ?>:<?php echo $this->exception->getLine() ?></pre> </dd> <dt><?php echo $this->translate('Message') ?>:</dt> <dd> <pre class="prettyprint linenums"><?php echo $this->exception->getMessage() ?></pre> </dd> <dt><?php echo $this->translate('Stack trace') ?>:</dt> <dd> <pre class="prettyprint linenums"><?php echo $this->exception->getTraceAsString() ?></pre> </dd> </dl> <?php $e = $this->exception->getPrevious(); if ($e) : ?> <hr/> <h2><?php echo $this->translate('Previous exceptions') ?>:</h2> <ul> <?php while($e) : ?> <li> <h3><?php echo get_class($e); ?></h3> <dl> <dt><?php echo $this->translate('File') ?>:</dt> <dd> <pre class="prettyprint linenums"><?php echo $e->getFile() ?>:<?php echo $e->getLine() ?></pre> </dd> <dt><?php echo $this->translate('Message') ?>:</dt> <dd> <pre class="prettyprint linenums"><?php echo $e->getMessage() ?></pre> </dd> <dt><?php echo $this->translate('Stack trace') ?>:</dt> <dd> <pre class="prettyprint linenums"><?php echo $e->getTraceAsString() ?></pre> </dd> </dl> </li> <?php $e = $e->getPrevious(); endwhile; ?> </ul> <?php endif; ?> <?php else: ?> <h3><?php echo $this->translate('No Exception available') ?></h3> <?php endif ?> <?php endif ?> ~~~ 代碼解釋: echo $this->message 輸出錯誤信息 if (isset($this->display_exceptions) && $this->display_exceptions) 判斷是否顯示異常信息 echo get_class($this->exception) 輸出異常類型名稱 echo $this->exception->getFile() 輸出導致異常的文件名 echo $this->exception->getLine() 輸出導致異常文件的所在行 echo $this->exception->getMessage() 輸出異常信息 echo $this->exception->getTraceAsString() 輸出異常堆棧信息 $e = $this->exception->getPrevious() 獲取上一個異常 以上是錯誤異常模板內容,模板能夠輸出導致錯誤異常的文件名、出錯所在行、錯誤類型等信息。在開發項目的時候便可以通過錯誤的信息提示來查找相關出錯原因。理解并正確使用使用錯誤信息能夠有效的提高開發效率。 ### 5.3.3 404錯誤模板 404.phtml 下面是代碼內容: ~~~ <h1><?php echo $this->translate('A 404 error occurred') ?></h1> <h2><?php echo $this->message ?></h2> <?php if (isset($this->reason) && $this->reason): ?> <?php $reasonMessage= ''; switch ($this->reason) { case 'error-controller-cannot-dispatch': $reasonMessage = $this->translate('The requested controller was unable to dispatch the request.'); break; case 'error-controller-not-found': $reasonMessage = $this->translate('The requested controller could not be mapped to an existing controller class.'); break; case 'error-controller-invalid': $reasonMessage = $this->translate('The requested controller was not dispatchable.'); break; case 'error-router-no-match': $reasonMessage = $this->translate('The requested URL could not be matched by routing.'); break; default: $reasonMessage = $this->translate('We cannot determine at this time why a 404 was generated.'); break; } ?> <p><?php echo $reasonMessage ?></p> <?php endif ?> <?php if (isset($this->controller) && $this->controller): ?> <dl> <dt><?php echo $this->translate('Controller') ?>:</dt> <dd><?php echo $this->escapeHtml($this->controller) ?> <?php if (isset($this->controller_class) && $this->controller_class && $this->controller_class != $this->controller ) { echo '(' . sprintf($this->translate('resolves to %s'), $this->escapeHtml($this->controller_class)) . ')'; } ?> </dd> </dl> <?php endif ?> <?php if (isset($this->display_exceptions) && $this->display_exceptions): ?> <?php if(isset($this->exception) && $this->exception instanceof Exception): ?> <hr/> <h2><?php echo $this->translate('Additional information') ?>:</h2> <h3><?php echo get_class($this->exception); ?></h3> <dl> <dt><?php echo $this->translate('File') ?>:</dt> <dd> <pre class="prettyprint linenums"><?php echo $this->exception->getFile() ?>:<?php echo $this->exception->getLine() ?></pre> </dd> <dt><?php echo $this->translate('Message') ?>:</dt> <dd> <pre class="prettyprint linenums"><?php echo $this->exception->getMessage() ?></pre> </dd> <dt><?php echo $this->translate('Stack trace') ?>:</dt> <dd> <pre class="prettyprint linenums"><?php echo $this->exception->getTraceAsString() ?></pre> </dd> </dl> <?php $e = $this->exception->getPrevious(); if ($e) : ?> <hr/> <h2><?php echo $this->translate('Previous exceptions') ?>:</h2> <ul> <?php while($e) : ?> <li> <h3><?php echo get_class($e); ?></h3> <dl> <dt><?php echo $this->translate('File') ?>:</dt> <dd> <pre class="prettyprint linenums"><?php echo $e->getFile() ?>:<?php echo $e->getLine() ?></pre> </dd> <dt><?php echo $this->translate('Message') ?>:</dt> <dd> <pre class="prettyprint linenums"><?php echo $e->getMessage() ?></pre> </dd> <dt><?php echo $this->translate('Stack trace') ?>:</dt> <dd> <pre class="prettyprint linenums"><?php echo $e->getTraceAsString() ?></pre> </dd> </dl> </li> <?php $e = $e->getPrevious(); endwhile; ?> </ul> <?php endif; ?> <?php else: ?> <h3><?php echo $this->translate('No Exception available') ?></h3> <?php endif ?> <?php endif ?> ~~~ 代碼解析: echo $this->message 輸出錯誤信息 if (isset($this->reason) && $this->reason) 判斷是否存在錯誤,$this->reason 有多種類型,控制器路由分發錯誤(error-controller-cannot-dispatch)、控制器不存在(error-controller-not-found)、無效控制器(error-controller-invalid)、路由不匹配(error-router-no-match)及其他 $this->controller 表示控制器名 $this->controller_class 表示控制器類名 以上內容是404錯誤提示模板內容;模板能夠輸出導致錯誤異常的文件名、出錯所在行、錯誤類型等信息。在后繼開發中可以通過404的相關提示信息找到出錯的問題點。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看