`
philix
  • 浏览: 80760 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

php.codeigniter小改造一下

    博客分类:
  • PHP
阅读更多
function safe_exit($message=''){
	//凡是die; eixt都被替换为safe_exit() 
	//所有代码中都不允许出现 die / exit的直接调用!
	
	//写个日志.begin{
	$f = fopen ( dirname(__FILE__)."/ci.log.txt", 'a+' );
	fwrite ( $f,"\n\n");
	fwrite ( $f,date("Y-m-d H:i:s",time()));
	fwrite ( $f,"$message\n");
	fwrite ( $f,var_export(debug_backtrace(),true));
	fclose ( $f );
	//写日志.end}
	
	exit($message);
}

 

下载个最新的codeigniter 2.0.2 , 用emeditor 打开index.php ,在文件中搜索(只匹配单词) 并替换

exit

die

 

全部替换为 safe_exit

 

safe_exit在index.php里实现,如上!

 

这样可恶的die / exit就再也不会给我一个白板页面了.

我开发的程序里,也是不允许直接出现die/ exit 的.

 

再配置一个 xdebug 单步调试,  万事就具备了!

 

工善其事,先利其器! 

 

修改完的ci代码, 打包在附件中了.推荐下载这个代替原版. 

即使将来升级, 也是很容易和官方同步的.

 

 

#end.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics