PHP debugging tool DebugTools_PHP tutorial

Source: Internet
Author: User
DebugTools, a PHP debugging tool. I found a good PHP source code debugging comrade: PHPDEBUGTOOLS. Project address: freshmeat. netprojectsphp-debug-tools File: freshmeat. neturls7c58ae3fecce57 found a good PHP source code debugging comrade: 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
Run the following code:

The code is as follows:


Require './lib/debug. php ';
Function test ($ a, $ B)
{
Echo $ asd;
}
Test (10, 'ABC ');
?>



2. Debug with Debug ()
Run the following code:

The code is as follows:


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:

The code is as follows:


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'

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.