刚刚看了几个推荐框架的帖子,蛮多推荐codeigniter的,请恕小弟我直言,那框架实在不敢恭维啊个人意见,仅供参考

WBOY
Release: 2016-06-13 12:50:00
Original
773 people have browsed it

刚刚看了几个推荐框架的帖子,蛮多推荐codeigniter的,请恕我直言,那框架实在不敢恭维啊~个人意见,仅供参考。
首先我是用过codeigniter的,刚开始学框架的时候用过一阵子,然后后来公司用thinkphp,就没再用了,用了2个之后,就会有一些对比性。首先这2个框架文件夹容量都比较大,称不上轻量级之类的,我都不怎么看好。
今天单说codeigniter框架
举个官网控制器调用模板的例子

<?php<br />
class Blog extends CI_Controller {<br />
<br />
 function index()<br />
 {<br />
  $data['title'] = "My Real Title";<br />
  $data['heading'] = "My Real Heading";<br />
  <br />
  $this->load->view('blogview', $data);<br />
 }<br />
}<br />
?> 
Copy after login

<html><br />
<head><br />
<title><?php echo $title;?></title><br />
</head><br />
<body><br />
 <h1><?php echo $heading;?></h1><br />
</body><br />
</html>
Copy after login


感觉这种模式很不好,难道这就是传说中的控制器模板分离?这种模式只能忽悠刚刚入门的那些PHPer,先不论调用smarty之类的来反驳我,只是说他的自身特性,而且什么框架都能结合smarty来用。

以上的代码用PHP的一个函数就能实现了,请查阅extract函数的用法。

很多用codeigniter的PHPer估计就是冲着所谓写法优美去的,可以用连贯写法-> ->

究其实质,并没有对模板(视图)产生有多大的作用,

只是把变量全部先计算出来,换个名称,再在需要的时候,把新名称填入到所需地方。

然后个人在国外网站闲逛的时候呢,发现一个模板,它和codeigniter的这种模式有很大的相似性。模板名未知,就叫他template吧。你们可以看看,就可以对codeigniter原理有大致的了解吧

它的核心模板代码我写一下

<?php <br />
//template.php<br>
/**<br>
 * Copyright (c) 2003 Brian E. Lozier (brian@massassi.net)<br>
 *<br>
 * Permission is hereby granted, free of charge, to any person obtaining a copy<br>
 * of this software and associated documentation files (the "Software"), to<br>
 * deal in the Software without restriction, including without limitation the<br>
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or<br>
 * sell copies of the Software, and to permit persons to whom the Software is<br>
 * furnished to do so, subject to the following conditions:<br>
 *<br>
 * The above copyright notice and this permission notice shall be included in<br>
 * all copies or substantial portions of the Software.<br>
 *<br>
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br>
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
 * IN THE SOFTWARE.<br>
 */<br>
<br>
class Template {<br>
	var $vars; /// Holds all the template variables<br>
	var $path; /// Path to the templates<br>
<br>
	/**<br>
	 * Constructor<br>
	 *<br>
	 * @param string $path the path to the templates<br>
	 *<br>
	 * @return void<br>
	 */ <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!