search
HomeBackend DevelopmentPHP Tutorial FirePHP的应用实例

FirePHP的使用实例
一.firePHP是什么

firePHP是一款ff的插件,用于将php调试信息输出到firebug控制台。

二.firePHP有什么用

在正式发布后,又不影响页面显示的情况下,调试php,将调试信息输出到控制台


三.firePHP安装

1。前提:需要安装ff的插件---firebug
2。安装:
a.在服务器端安装FirePHPCore 组件
b.将包放到项目目录下(假设firePHPCore放到项目根目录下)
c.服务端使用方式(导入包)
d、开启客户端
开启Firebug 控制台、脚本、网络。
将当前网站添加入FirePHP允许站点

3.使用

require('FirePHPCore/fb.php'); //导入包

/* NOTE: You must have Output Buffering enabled via
         ob_start() or output_buffering ini directive. */
/*
  打开输出缓冲(因为Firephp主要用到的是header函数),有如下三种方法:
	* 在程序的前面加上ob_start()
	* 修改php.ini 将output_buffering设为1或者on
	* 修改apache的设置,在配置文件中加上php_flag output_buffering on
*/

ob_start();

/*
  开始调试:可以调试输出以下数据类型:
	* 字符串,可以分为LOG,INFO,WARN,ERROR四种
	  都会在console中显示出一行结果,只不过显示的图标不同页已.
	* Object或者Array
	* 通过sql查询返回的数据
	* 抛出的异常信息
	* 服务器返回的信息(不输出在console中,而是NET中
*/

fb('Hello World'); /* Defaults to FirePHP::LOG */

fb('Log message'  ,FirePHP::LOG);	//==fb('Log message','LOG');==fb('Log message');
fb('Info message' ,FirePHP::INFO);	//==fb('Info message' ,'INFO');
fb('Warn message' ,FirePHP::WARN);	//==fb('Warn message' ,'WARN');
fb('Error message',FirePHP::ERROR);	//==fb('Error message','ERROR');

/*
fb函数:参数一为需要显示的任意值(string|array|integer…)
参数二如果不是类型时,则为这行的标签。例fb(’string’,'label’,FirePHP::LOG)
则在console中显示为 label:string
*/
fb('Message with label','Label',FirePHP::LOG);

fb(array('key1'=>'val1',
         'key2'=>array(array('v1','v2'),'v3')),
   'TestArray',FirePHP::LOG);



function test($Arg1) {
  throw new Exception('Test Exception');
}
try {
  test(array('Hello'=>'World'));
} catch(Exception $e) {
  /* Log exception including stack trace & variables */
  fb($e);
}
/*
  FirePHP::TABLE
  会在console中显示出一个表格.
  参数一的数组下标0的值为要显示的标题
  参数一的数组下标1的值为要显示的行的信息
*/
fb(array('2 SQL queries took 0.06 seconds',array(
   array('SQL Statement','Time','Result'),
   array('SELECT * FROM Foo','0.02',array('row1','row2')),
   array('SELECT * FROM Bar','0.04',array('row1','row2'))
  )),FirePHP::TABLE);

/*
FirePHP::DUMP
会在NET标签下的此页面请求的Server标签下显示你要输出的信息。
*/
/* Will show only in "Server" tab for the request */
fb(apache_request_headers(),'RequestHeaders',FirePHP::DUMP);

print 'Hello World';


还有点需要注意,为了数据的安全,在修改完bug正式发布的时候,需要FB::setEnabled(false); 调试信息将不再输出到控制台
Statement
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
PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

How to make PHP applications fasterHow to make PHP applications fasterMay 12, 2025 am 12:12 AM

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

PHP Performance Optimization Checklist: Improve Speed NowPHP Performance Optimization Checklist: Improve Speed NowMay 12, 2025 am 12:07 AM

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

PHP Dependency Injection: Improve Code TestabilityPHP Dependency Injection: Improve Code TestabilityMay 12, 2025 am 12:03 AM

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

PHP Performance Optimization: Database Query OptimizationPHP Performance Optimization: Database Query OptimizationMay 12, 2025 am 12:02 AM

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment