关于CodeIgniter视图使用注意事项
来源:才华咖 本文已影响1.19W人
来源:才华咖 本文已影响1.19W人
本文讲述了CodeIgniter视图使用注意事项。分享给大家供大家参考,具体如下:
CI中视图即application/views/下的模版文件,模版中支持直接使用PHP,所以模版的实现没有太多好说的',说几点视图的注意事项:
1、CI的视图可以在控制器中load多个视图,页面最后将这些内容组合起来后输出。这里load的动作如果交给控制器去做,需要调整模版结构时就需要调整控制器,这不太好。可以在控制器中进行封装或者直接交给视图去做,保证每个ACTION都只load一个视图文件。
2、让视图做它擅长的事情,不要在PHP代码中直接定义HTML,这样子会让程序和视图都难以维护,如果要加载HTML,可通过load的方式返回。
3、虽然有万能的get_instance方法,但在视图中也不要直接去读取数据或者做一些其他模块的事情。视图的作用就是接收数据并展现出来,以确保人尽其责,物尽其用。
4、关于是否要使用模版的问题,个人趋向于使用模版。直接使用PHP时,需要自己去处理变量的定义问题、转换为HTML实体的问题,而这些问题模版都可以解决,以及会提供一些更方便的操作。如果要说效率问题,不在这里,也大多不在PHP。
希望本文所述对大家基于CodeIgniter框架的PHP程序设计有所帮助。
英语作文:Reading Outside The College
Food and place of interest in Beijing初中英语作文
英语高分作文:The importance of protecting the environment
One Thing I Experienced高中英语作文
java script remove Child的使用注意事项
The place of Science and Technology in Modern Life英语作文
A Bitter Experience in My Childhood初中英语作文
Ought Parents to Give Children Pocket英语作文
奥运英语作文:中国跳水队(Diving into Gold: Chinas Dream Team
英语作文: The Uncivilized Internet Words
PHP项目中CodeIgniter使用的建议
My experience with foreign coins初中英文作文
英语作文OnFabricatingAcademicCredentials
九年级《unit 6 I like music that I can dance to. Period2》评课稿
英语作文My Experience With Foreign Coins
英语口语:Teaching and Learning Responsibility
使用手机的注意事项
《Unit 2 I don’t like riding bikes》说课稿范文
八年级Unit 5 What were you doing when the rainstorm came?教学设计
Should Private Cars Be Encouraged in China高中英语作文
会议室使用注意事项
《the most interesting stories》湘少版六下Unit7的相关知识及
关于移动硬盘使用的注意事项
分享SAT阅读练习题:Reading Comprehension Test 14
the most interesting subjuct and thing英语作文
英语作文International Day of Peace Vigil
我的英语演讲稿living at present is my top concern
DOS的Interlnk、Intersvr、Qbasic命令使用说明
八年级《unit8 Why don’t you get her a scarf? Period1》评课稿
The importance of keep in a good mood英语作文
The Origin of Chinese New Year英语作文
英语作文:I thinh you can be good friends
高中英语作文:My approach to difficulties in learning
protecting the environment英语作文
The relationship between theory and practice大学英语作文
如何使用Google-Code-Prettify 实现代码高亮功能
Module 4 Unit1 We’re going to tell stories.教学设计
should women work after getting married英语作文
Win10系统提示Officebackgroundtaskhandler.exe弹窗问题的解决方
关于党费使用、报销流程及注意事项的说明