FirePHP的应用实例+注释
FirePHP的使用实例+注释
一.firePHP是什么
firePHP是一款ff的插件,用于将php调试信息输出到firebug控制台。
二.firePHP有什么用
在正式发布后,又不影响页面显示的情况下,调试php,将调试信息输出到控制台
三.firePHP安装
1。前提:需要安装ff的插件---firebug
2。安装:
a.在服务器端安装FirePHPCore 组件
b.将包放到项目目录下(假设firePHPCore放到项目根目录下)
c.服务端使用方式(导入包)
d、开启客户端
开启Firebug 控制台、脚本、网络。
将当前网站添加入FirePHP允许站点
3.使用
Php代码 收藏代码
1. require('FirePHPCore/fb.php'); //导入包
2.
3. /* NOTE: You must have Output Buffering enabled via
4. ob_start() or output_buffering ini directive. */
5. /*
6. 打开输出缓冲(因为Firephp主要用到的是header函数),有如下三种方法:
7. * 在程序的前面加上ob_start()
8. * 修改php.ini 将output_buffering设为1或者on
9. * 修改apache的设置,在配置文件中加上php_flag output_buffering on
10. */
11.
12. ob_start();
13.
14. /*
15. 开始调试:可以调试输出以下数据类型:
16. * 字符串,可以分为LOG,INFO,WARN,ERROR四种
17. 都会在console中显示出一行结果,只不过显示的图标不同页已.
18. * Object或者Array
19. * 通过sql查询返回的数据
20. * 抛出的异常信息
21. * 服务器返回的信息(不输出在console中,而是NET中
22. */
23.
24. fb('Hello World'); /* Defaults to FirePHP::LOG */
25.
26. fb('Log message' ,FirePHP::LOG); //==fb('Log message','LOG');==fb('Log message');
27. fb('Info message' ,FirePHP::INFO); //==fb('Info message' ,'INFO');
28. fb('Warn message' ,FirePHP::WARN); //==fb('Warn message' ,'WARN');
29. fb('Error message',FirePHP::ERROR); //==fb('Error message','ERROR');
30.
31. /*
32. fb函数:参数一为需要显示的任意值(string|array|integer…)
33. 参数二如果不是类型时,则为这行的标签。例fb(’string’,'label’,FirePHP::LOG)
34. 则在console中显示为 label:string
35. */
36. fb('Message with label','Label',FirePHP::LOG);
37.
38. fb(array('key1'=>'val1',
39. 'key2'=>array(array('v1','v2'),'v3')),
40. 'TestArray',FirePHP::LOG);
41.
42.
43.
44. function test($Arg1) {
45. throw new Exception('Test Exception');
46. }
47. try {
48. test(array('Hello'=>'World'));
49. } catch(Exception $e) {
50. /* Log exception including stack trace & variables */
51. fb($e);
52. }
53. /*
54. FirePHP::TABLE
55. 会在console中显示出一个表格.
56. 参数一的数组下标0的值为要显示的标题
57. 参数一的数组下标1的值为要显示的行的信息
58. */
59. fb(array('2 SQL queries took 0.06 seconds',array(
60. array('SQL Statement','Time','Result'),
61. array('SELECT * FROM Foo','0.02',array('row1','row2')),
62. array('SELECT * FROM Bar','0.04',array('row1','row2'))
63. )),FirePHP::TABLE);
64.
65. /*
66. FirePHP::DUMP
67. 会在NET标签下的此页面请求的Server标签下显示你要输出的信息。
68. */
69. /* Will show only in "Server" tab for the request */
70. fb(apache_request_headers(),'RequestHeaders',FirePHP::DUMP);
71.
72. print 'Hello World';
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); 调试信息将不再输出到控制台
参考资料:http://blog.csdn.net/john_shen_tiro1/archive/2009/04/14/4071212.aspx
http://blog.csdn.net/leijuly/archive/2009/05/31/4227613.aspx

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The message "Your organization has asked you to change your PIN" will appear on the login screen. This happens when the PIN expiration limit is reached on a computer using organization-based account settings, where they have control over personal devices. However, if you set up Windows using a personal account, the error message should ideally not appear. Although this is not always the case. Most users who encounter errors report using their personal accounts. Why does my organization ask me to change my PIN on Windows 11? It's possible that your account is associated with an organization, and your primary approach should be to verify this. Contacting your domain administrator can help! Additionally, misconfigured local policy settings or incorrect registry keys can cause errors. Right now

Windows 11 brings fresh and elegant design to the forefront; the modern interface allows you to personalize and change the finest details, such as window borders. In this guide, we'll discuss step-by-step instructions to help you create an environment that reflects your style in the Windows operating system. How to change window border settings? Press + to open the Settings app. WindowsI go to Personalization and click Color Settings. Color Change Window Borders Settings Window 11" Width="643" Height="500" > Find the Show accent color on title bar and window borders option, and toggle the switch next to it. To display accent colors on the Start menu and taskbar To display the theme color on the Start menu and taskbar, turn on Show theme on the Start menu and taskbar

By default, the title bar color on Windows 11 depends on the dark/light theme you choose. However, you can change it to any color you want. In this guide, we'll discuss step-by-step instructions for three ways to change it and personalize your desktop experience to make it visually appealing. Is it possible to change the title bar color of active and inactive windows? Yes, you can change the title bar color of active windows using the Settings app, or you can change the title bar color of inactive windows using Registry Editor. To learn these steps, go to the next section. How to change title bar color in Windows 11? 1. Using the Settings app press + to open the settings window. WindowsI go to "Personalization" and then

Do you see "A problem occurred" along with the "OOBELANGUAGE" statement on the Windows Installer page? The installation of Windows sometimes stops due to such errors. OOBE means out-of-the-box experience. As the error message indicates, this is an issue related to OOBE language selection. There is nothing to worry about, you can solve this problem with nifty registry editing from the OOBE screen itself. Quick Fix – 1. Click the “Retry” button at the bottom of the OOBE app. This will continue the process without further hiccups. 2. Use the power button to force shut down the system. After the system restarts, OOBE should continue. 3. Disconnect the system from the Internet. Complete all aspects of OOBE in offline mode

Taskbar thumbnails can be fun, but they can also be distracting or annoying. Considering how often you hover over this area, you may have inadvertently closed important windows a few times. Another disadvantage is that it uses more system resources, so if you've been looking for a way to be more resource efficient, we'll show you how to disable it. However, if your hardware specs can handle it and you like the preview, you can enable it. How to enable taskbar thumbnail preview in Windows 11? 1. Using the Settings app tap the key and click Settings. Windows click System and select About. Click Advanced system settings. Navigate to the Advanced tab and select Settings under Performance. Select "Visual Effects"

We all have different preferences when it comes to display scaling on Windows 11. Some people like big icons, some like small icons. However, we all agree that having the right scaling is important. Poor font scaling or over-scaling of images can be a real productivity killer when working, so you need to know how to customize it to get the most out of your system's capabilities. Advantages of Custom Zoom: This is a useful feature for people who have difficulty reading text on the screen. It helps you see more on the screen at one time. You can create custom extension profiles that apply only to certain monitors and applications. Can help improve the performance of low-end hardware. It gives you more control over what's on your screen. How to use Windows 11

Screen brightness is an integral part of using modern computing devices, especially when you look at the screen for long periods of time. It helps you reduce eye strain, improve legibility, and view content easily and efficiently. However, depending on your settings, it can sometimes be difficult to manage brightness, especially on Windows 11 with the new UI changes. If you're having trouble adjusting brightness, here are all the ways to manage brightness on Windows 11. How to Change Brightness on Windows 11 [10 Ways Explained] Single monitor users can use the following methods to adjust brightness on Windows 11. This includes desktop systems using a single monitor as well as laptops. let's start. Method 1: Use the Action Center The Action Center is accessible

In iOS 17, Apple introduced several new privacy and security features to its mobile operating system, one of which is the ability to require two-step authentication for private browsing tabs in Safari. Here's how it works and how to turn it off. On an iPhone or iPad running iOS 17 or iPadOS 17, Apple's browser now requires Face ID/Touch ID authentication or a passcode if you have any Private Browsing tab open in Safari and then exit the session or app to access them again. In other words, if someone gets their hands on your iPhone or iPad while it's unlocked, they still won't be able to view your privacy without knowing your passcode
