PHP Debug Tool Debug tools_php Tutorial

Source: Internet
Author: User
Tags php debug php source code
Found a good comrade debugging PHP source code: PHP Debug TOOLS

Its Project address: http://freshmeat.net/projects/php-debug-tools/
File Download Address: http://freshmeat.net/urls/7c58ae3fecce5763e7546b958d36e082
Current version 1.03


The occasional environment here is window XP, APACHE2.2, php5.2+ Zend Optimizer,
This is explained in conjunction with the PHP DEBUG tools Help documentation, some of which are excerpted from the documentation.

I. Installation Chapter
Pre-installation Environment: X-debug must be installed first,
As for how to install x-debug please see Http://www.xdebug.org/docs/install

1. Download the appropriate X-debug version from http://www.xdebug.org/download.php
2. Unzip the DLL file to the Ext directory in 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 to add the following paragraph:
-------------I'm a perverted dividing line, you can't see me------------------------
Zend_extension = "C:/php/ext/php_xdebug-2.0.4-5.2.8-nts.dll"
Xdebug.collect_includes = Off
Xdebug.default_enable = Off

Xdebug.dump_globals = Off
Xdebug.dump_once = Off
Xdebug.extended_info = Off
-------------I'm a perverted dividing line, you can't see me------------------------
Note: This example are for Non-thread safe version. For the thread safe version change "zend_extension" to "Zend_extension_ts"

After installation, unzip all the files in the PHP DEBUG tools archive to the website publishing directory.
(Assuming the publish directory is c:\www, then just create a new debug directory and throw all the files in it)

In the browser, type: http://localhost/debug/test1-debug.php
If you see the installation succeeds.

two. The Debug chapter
1.Debug errors
such as the following code:
Copy CodeThe code is as follows:
Require './lib/debug.php ';
function test ($a, $b)
{
Echo $ASD;
}
Test (, ' abc ');
?>


2. Debug with Debug ()
such as the following code:
Copy CodeThe 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 ()
such as the following code:
Copy CodeThe 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 ();
?>


As for Dump_tofile () it is generally used in the following situations:
A. When you don't want to stop the program from running
B. Not that you don't want to show the modal data, but that you can't. For example, when you are in the AJAX request state.
C. You also want to be in many places

Refer to the test7-dump_tofile.php in the debug directory

Note: When I run dump () or dump_tofile (), I find that I cannot see the PHP DEBUG tool document as described in

This can be corrected by modifying the debug/lib/debug.php code. (Because Dump_tofile () has a call to dump (), so we just need to modify one place.
At line 149.
Echo $pre;

Modified to:

Edit by Benben---start
Echo ';
Edit by Benben---End

The revised figure:

4. Tracking code, viewing system performance
You can browse the test3-trace.php in the directory, then click the Console on the lower right corner.
Refer to the documentation for details. (The document is in the doc directory within the zipped package)
third, how to integrate with the project?

First of all, the PHP Debug tool decompression files, placed in the project directory, build a directory called Debug it! : )
All we need is just a few documents.
For example, the path is: C:\www\projectName\debug

After that, there are two ways to debug
First, you can add such a sentence to the project source code:
Include_once ('./lib/debug.php ');

For example, the following: c:\www\projectName\hellodebug\index.php
Copy CodeThe code is as follows:
Include_once ('./debug/lib/debug.php ');

$faint = ' HelloWorld, debuging ';

Debug ($ARRB);
?>


What, you don't want every page to be written like that?
So look at the second method,
There are two ways of doing this,
1. Modify PHP.ini Add the following (modify 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 not even tried, hey)
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 makes it easy to debug the entire project.

In the case of Ajax development, there is a need, please refer to the documentation. (because I do not have that need, so temporarily first jump open, do not shoot bricks, hey.)

http://www.bkjia.com/PHPjc/323238.html www.bkjia.com true http://www.bkjia.com/PHPjc/323238.html techarticle I found a good comrade debugging PHP source code: PHP Debug TOOLS Its Project address: http://freshmeat.net/projects/php-debug-tools/file Download Address:/http Freshmeat.net/urls/7c58ae3fecce57 ...

  • 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.