codecamp

PHP 命名规则

提取出来具有通用函数的包含文件,文件后缀以.inc来命名,表明这是一个包含文件。
如果有多个.inc文件需要包含多页面,请把所有.inc文件封装在一个文件里面,具体到页面只需要包换一个.inc文件就可以了
如:xxx_session.inc
xxx_comm..inc
xxx_setting.inc
mysql_db.inc

把以上文件以一下方式,封装在xxx.basic.inc文件里面
require_once(”xxx_session.inc”);
require_once(”xxx_comm.inc”);
require_once(”xxx_setting.inc”);
require_once(”mysql_db.inc”);

注:是否需要封装到一个文件,视情况而定,如果每个inc的功能是分散到不同的页面使用的话,就不建议封装。


第三章 PHP安全规范
PHP 存放规则
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

第一章 PHP编写规范

第二章 PHP整体要求

第五章 特定环境下PHP编码特殊规范

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }