Home  >  Article  >  php教程  >  thinphp5 rc3 页面头尾分离

thinphp5 rc3 页面头尾分离

WBOY
WBOYOriginal
2016-06-07 11:34:401165browse

页面的公共部分加载方法 有问题 求大神补刀
 //公共视图 头尾分离   common控制器下加载的方法<br> public function common_view($view_content)<br> {<br>         header("Content-type: text/html; charset=utf-8");<br>         //实例化视图类 <br>          $view = new \think\View('',\think\Config::get('view_replace_str'));<br>         //获取当前所在页面的内容 并 将内容传输到页面中<br>         $view->content = $view_content; <br>         //加载 页面公共部分视图<br>         return $view->fetch('common/common');<br> }<br> <br> <br> //页面加载   其他控制器下(都继承common控制器)  加载的方式   <br> public function index(){<br>         $view = new \think\View();<br>       //加载视图  获取当前所在页面的内容<br>       $view_content = $view->fetch(); <br>       return self::common_view($view_content);<br>  }<br> <br> 在配置文件config中添加<br> //配置系统变量<br>     'view_replace_str'=>[<br>         '__PUBLIC__'=>'/public/',<br>         '__ROOT__' => '/',<br>     ]

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
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