PHP debugging tool debug tools

Source: Internet
Author: User
Tags php debug

I found a good comrade who debugged the PHP source code: PhP debug tools

Its project address: http://freshmeat.net/projects/php-debug-tools/
File: http://freshmeat.net/urls/7c58ae3fecce5763e7546b958d36e082
Version 1.03

The environment here is Windows XP, apache2.2, php5.2 + Zend optimizer,
Here, we will use the help document of PHP debug tools to explain some of the figures are taken from the document.

I. Installation
Preparations before installation: X-Debug must be installed first,
See http://www.xdebug.org/docs/install for how to install x-Debug

1. Download your x-debugversion from http://www.xdebug.org/download.php
2. decompress the DLL file to the ext directory under the PHP installation directory, such as C:/PHP/EXT/php_xdebug-2.0.4-5.2.8-nts.dll
3. Modify the php. ini file and add the following content:
------------- Even abnormal split line, you cannot see me ------------------------
Zend_extension = "C:/PHP/EXT/php_xdebug-2.0.4-5.2.8-nts.dll"
Xdebug. collect_effecdes = off
Xdebug. default_enable = off

Xdebug. dump_globals = off
Xdebug. dump_once = off
Xdebug. extended_info = off
------------- Even abnormal split line, you cannot see me ------------------------
Note: This example is for non-thread safe version. For the thread safe version change "zend_extension" to "zend_extension_ts"

After installation, decompress all the files in the PHP debug tools package to the website release directory.
(Assume that the release directory is c: \ www, then create a new DEBUG directory and throw all the files into it)

Enter: http: // localhost/debug/test1-debug.php in the browser
If yes, the installation is successful.

Ii. debugging
1. debug errors
See the followingCode:Copy codeThe Code is as follows: <? PHP
Require './lib/debug. php ';
Function Test ($ A, $ B)
{
Echo $ ASD;
}
Test (10, 'abc ');
?>


2. debug with debug ()
Run the following code:Copy codeThe Code is as follows: <? PHP
Require './lib/debug. php ';
Function Test ($ ARGs)
{
Test_nested ($ ARGs );
}
Function test_nested ($ ARGs)
{
Debug ($ ARGs );
// Or: Debug (get_defined_vars ());
// Or: Debug ();
}
Test (Array ('id' => 123, 'str' => 'test '));
?>


3. debug with dump () or dump_tofile ()
Run the following code:Copy codeThe Code is as follows: <? PHP
Include_once './lib/dump. php ';
Function test5 ()
{
Include './testdata/test0.php ';
$ Test = array ('int' => 1, 'float' => 2.0, 'float2' => 2.1 );
Dump ($ test, $ _ server );
}
Function test1 () {Test2 ();}
Function Test2 () {test3 ();}
Function test3 () {test4 ();}
Function test4 () {test5 ();}
Test1 ();
?>


Dump_tofile () is generally used in the following scenarios:
A. When you don't want to stop running the program
B. You don't want to display the adjustment data, but you don't. For example, when you are in the Ajax Request status.
C. You want to adjust it in multiple places

See the test7-dump_tofile.php In the DEBUG directory

Note: When I run dump () or dump_tofile (), I find that the PHP debug tool documentation does not appear.

Here we can modify the debug/lib/debug. PHP code to correct it. (because dump_tofile () has been called to dump (), we only need to modify one.
At 149 rows
Echo $ pre;

Modify:

// Edit by Benben --- start
Echo '<SCRIPT type = "text/JavaScript"> ';
Echo 'document. Write (';
Echo $ pre;
Echo ');';
Echo '</SCRIPT> ';
// Edit by Benben --- end

Corrected graph:

4. Track code and view system performance
You can browse the test3-trace.php under the directory, and then click the console in the lower right corner.
For details, refer to the document. (the document is in the doc directory of the compressed package)
3. How to integrate with projects?

First, decompress the PHP debug tool file and place it in the project directory. Create a directory named debug! :)
In fact, we only need a few files.
For example, the path is c: \ www \ projectname \ debug.

Then, we can debug it in two ways.
First, you can add the following sentence to the project source code:
Include_once ('./lib/debug. php ');

Example: C: \ www \ projectname \ hellodebug \ index. phpCopy codeThe Code is as follows: <? PHP
Include_once ('./debug/lib/debug. php ');

$ Faint = 'helloworld, debucket ';

Debug ($ arrb );
?>

What? Do you want to write such a sentence on every page?
So let's look at the second method,
There are also two methods,
1. Modify PHP. ini and add the following content (to your own directory ):
Auto_prepend_file = "C: \ www \ projectname \ debug \ auto_prepend.php"
Auto_append_file = "C: \ www \ projectname \ debug \ auto_append.php"

2. Modify the. htaccess file (Note: This method has never been tried,)
Php_value auto_prepend_file "C: \ www \ projectname \ debug \ auto_prepend.php"
Php_value auto_append_file "C: \ www \ projectname \ debug \ auto_append.php"

This facilitates debugging of the entire project.

For more information about Ajax development, see the document .)

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.