Application examples of firephp + annotations

Source: Internet
Author: User
firephp Usage examples + annotations
I. What is firephp?

The firephp is a plug-in for the FF that outputs PHP debugging information to the Firebug console.

Two. What's the use of firephp?

After the official release, without affecting the page display, debug PHP, output debugging information to the console



Three. firephp Installation

1. Prerequisite: Plug-in---firebug to install FF
2. Installation:
A. Installing the Firephpcore component on the server side
B. Place the package under the project directory (assuming Firephpcore is placed in the project root)
C. Server-side usage (Import package)
D. Turn on the client
Turn on Firebug console, scripts, network.
Add the current site to firephp allow site

3. Use
PHP Code Collection Code

1. require (' firephpcore/fb.php '); Importing packages
2.
3./* Note:you must have Output buffering enabled via
4. Ob_start () or output_buffering INI directive. */
5./*
6. Open the output buffer (because firephp is mainly used for the header function), there are three ways:
7. * Add Ob_start () to the front of the program
8. * Modify PHP.ini to set output_buffering to 1 or on
9. * Modify Apache settings, add php_flag output_buffering on in config file
10. */
11.
Ob_start ();
13.
14./*
15. Start Debugging: You can debug the output of the following data types:
16. * String, can be divided into log,info,warn,error four kinds
17. A row of results will be displayed in the console, except that the displayed icons are different pages.
* Object or array
19. * Data returned by SQL query
20. * Exception Information thrown
21. * Information returned by the server (not output in console, but net
22. */
23.
FB (' Hello world '); /* Defaults to Firephp::log */
25.
. 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 ');
30.
31./*
FB function: Parameter one is any value that needs to be displayed (String|array|integer ...)
33. Parameter Two if the type is not, then the label for this row. Example FB (' String ', ' label ', Firephp::log)
34. Display as label:string in console
35. */
FB (' Message with label ', ' label ', Firephp::log);
37.
. FB (' key1 ' = ' val1 ',
The ' Key2 ' =>array (Array (' v1 ', ' v2 '), ' V3 '),
"Testarray", Firephp::log);
41.
42.
43.
The. function test ($Arg 1) {
A. throw new Exception (' Test Exception ');
46.}
. try {
The. Test (Array (' Hello ' = = ' world ');
.} catch (Exception $e) {
./* Log exception including stack trace & variables */
. FB ($E);
52.}
53./*
Firephp::table.
55. A table is displayed in the console.
56. Array of parameter one the value of subscript 0 is the caption to be displayed
57. Array of parameter one the value of subscript 1 is the information of the row to be displayed
58. */
A. FB (Array (' 2 SQL queries took 0.06 seconds ', array (
Array (' SQL Statement ', ' time ', ' Result '),
A. Array (' SELECT * from Foo ', ' 0.02 ', Array (' Row1 ', ' row2 ')),
. Array (' SELECT * from Bar ', ' 0.04 ', array (' Row1 ', ' row2 '))
)), firephp::table);
64.
65./*
firephp::D UMP
67. The information you want to output will be displayed under the Server tab of this page under the Net tab.
68. */
*/* 'll show only in "Server" tab for the request */
(Apache_request_headers () fb (), ' Requestheaders ', firephp::D UMP);
71.
print ' Hello world ';

Require (' firephpcore/fb.php '); Importing packages

/* Note:you must have Output buffering enabled via
Ob_start () or output_buffering INI directive. */
/*
Open the output buffer (because firephp is mainly used by the header function), there are three ways:
* Add Ob_start () to the front of the program
* Modify PHP.ini to set output_buffering to 1 or on
* Modify Apache settings, add php_flag output_buffering on in config file
*/

Ob_start ();

/*
Start Debugging: You can debug the output of the following data types:
* String, can be divided into log,info,warn,error four kinds
will display a row of results in the console, except that the icons displayed are different pages.
* Object or array
* data returned via SQL query
* Exception information thrown
* Information returned by the server (not output in console, but 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 function: Parameter one is any value that needs to be displayed (String|array|integer ...)
Parameter two if the type is not, then the label for this row. Example FB (' String ', ' label ', Firephp::log)
is displayed as label:string in the console
*/
FB (' Message with label ', ' label ', Firephp::log);

FB (Array (' key1 ' = ' val1 ',
' Key2 ' =>array (Array (' v1 ', ' v2 '), ' V3 '),
' Testarray ', firephp::log);



function test ($Arg 1) {
throw new Exception (' Test Exception ');
}
try {
Test (Array (' Hello ' = ' world '));
} catch (Exception $e) {
/* Log exception including stack trace & variables */
FB ($E);
}
/*
Firephp::table
A table is displayed in the console.
The value of the array subscript 0 for the parameter one is the caption to be displayed
The value of the array subscript 1 of the parameter one is the information of the row to be displayed
*/
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::D UMP
The information you want to output is displayed under the Server tab of this page under the Net tab.
*/
/* would show only in "Server" tab for the request */
FB (Apache_request_headers (), ' Requestheaders ', firephp::D UMP);

print ' Hello world ';




There is also a need to note that in order to secure the data, in the revision of the bug when the official release, the need to fb::setenabled (false); Debug information will no longer be output to the console

Reference: Http://blog.csdn.net/john_shen_tiro1/archive/2009/04/14/4071212.aspx
Http://blog.csdn.net/leijuly/archive/2009/05/31/4227613.aspx
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.