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

PHPisusedforsendingemailsduetoitsintegrationwithservermailservicesandexternalSMTPproviders,automatingnotificationsandmarketingcampaigns.1)SetupyourPHPenvironmentwithawebserverandPHP,ensuringthemailfunctionisenabled.2)UseabasicscriptwithPHP'smailfunct

The best way to send emails is to use the PHPMailer library. 1) Using the mail() function is simple but unreliable, which may cause emails to enter spam or cannot be delivered. 2) PHPMailer provides better control and reliability, and supports HTML mail, attachments and SMTP authentication. 3) Make sure SMTP settings are configured correctly and encryption (such as STARTTLS or SSL/TLS) is used to enhance security. 4) For large amounts of emails, consider using a mail queue system to optimize performance.

CustomheadersandadvancedfeaturesinPHPemailenhancefunctionalityandreliability.1)Customheadersaddmetadatafortrackingandcategorization.2)HTMLemailsallowformattingandinteractivity.3)AttachmentscanbesentusinglibrarieslikePHPMailer.4)SMTPauthenticationimpr

Sending mail using PHP and SMTP can be achieved through the PHPMailer library. 1) Install and configure PHPMailer, 2) Set SMTP server details, 3) Define the email content, 4) Send emails and handle errors. Use this method to ensure the reliability and security of emails.

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.

ThebestpracticesforsendingemailssecurelyinPHPinclude:1)UsingsecureconfigurationswithSMTPandSTARTTLSencryption,2)Validatingandsanitizinginputstopreventinjectionattacks,3)EncryptingsensitivedatawithinemailsusingOpenSSL,4)Properlyhandlingemailheaderstoa


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

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

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version
Recommended: Win version, supports code prompts!

Dreamweaver Mac version
Visual web development tools
