技术头条 - 一个快速在微博传播文章的方式     搜索本站
您现在的位置首页 --> PHP --> FirePHP,给力的调试工具

FirePHP,给力的调试工具

浏览:2730次  出处信息

FirePHP功能就是将调试信息输出到http头信息上,不影响页面显示;
这样就特别适用ajax的调试,也适用线上产品不停止运行的调试。

  • firefox下安装firebug
  • 再安装firephp
  • 再把FirePHPCore的php类导入到你的程序中

FirePHPCore的lib包里有四个文件,后缀为php4的明显是适用php4的。

简单应用:

require_once('FirePHPCore/fb.php');
//以下按照类型进行信息记录
FB::log('Plain Message');
FB::info('Info Message');
FB::warn('Warn Message');
FB::error('Error Message');

分组应用:

require_once('FirePHPCore/fb.php');
FB::group('Group A'); // 分组  
//以下按照类型进行信息记录
FB::log('Plain Message');
FB::info('Info Message');
FB::warn('Warn Message');
FB::error('Error Message');
FB::groupEnd();

FB::group('Group B'); // 分组  
//以下按照类型进行信息记录
FB::log('Plain Message B');
FB::info('Info Message B');
FB::warn('Warn Message B');
FB::error('Error Message B');
FB::groupEnd();

按table应用:

require_once('FirePHPCore/fb.php');
$table[] = array('1', '2', '3');
$table[] = array('11', '22', '33');
$table[] = array('111', '222', '333');

FB:table('The table', $table);

好的,现在再说说如何与CodeIgniter结合使用。

  1. 将FirePHP.class.php、fb.php移动至system/application/libraries
  2. 重命名:FirePHP.class.php=>Firephp.php,fb.php=>Fb.php
  3. 编辑两个文件的第一行,改为:
    <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  4. 注释掉fb.php的第45行://require_once dirname(__FILE__).’/FirePHP.class.php’;
  5. 编辑(或增加)config/autoload.php :$autoload['libraries'] = array(“firephp”, “fb”);

demo:

function index()  
{  
    $this->fb->group('Group A'); // 分组  
    //以下按照类型进行信息记录
    $this->fb->log('Plain Message');
    $this->fb->info('Info Message');
    $this->fb->warn('Warn Message');
    $this->fb->error('Error Message');
    $this->fb->groupEnd();
       
    $this->fb->group('Group B'); // 分组  
    //以下按照类型进行信息记录
    $this->fb->log('Plain Message B');
    $this->fb->info('Info Message B');
    $this->fb->warn('Warn Message B');
    $this->fb->error('Error Message B');
    $this->fb->groupEnd();
}

效果:

完了,就是贴图太麻烦了:(

建议继续学习:

  1. 网络数据包调试利器之wireshark    (阅读:18245)
  2. 内存越界的概念和调试方法    (阅读:6126)
  3. GDB中应该知道的几个调试方法    (阅读:5295)
  4. webapp网页调试工具Chrome Devtools    (阅读:5016)
  5. php调试利器之phpdbg    (阅读:4366)
  6. 如何在Windows下编译或调试MySQL    (阅读:3422)
  7. 如何调试PHP的Core之获取基本信息    (阅读:2181)
  8. BTrace使用简介    (阅读:2080)
  9. 思考mysql之初级系列10---mysql内核调试方法    (阅读:2050)
  10. perl的调试    (阅读:2014)
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
© 2009 - 2024 by blogread.cn 微博:@IT技术博客大学习

京ICP备15002552号-1