PHP Debugging Tools Debug Tools_php Tips

Source: Internet
Author: User
Tags php debug php debugging tools 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
Now it's version 1.03.


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

I. Installation article
Pre-Installation Preparation environment: must first install X-debug,
As for how to install X-debug, please see Http://www.xdebug.org/docs/install

1. Download the appropriate version of your x-debug from http://www.xdebug.org/download.php
2. Extract DLL files 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. Revise the php.ini document and add the following paragraph:
-------------I'm a twisted split 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 twisted split line, you can't see me------------------------
Note: This example was for Non-thread safe version. For the thread safe version of "Zend_extension" to "Zend_extension_ts"

After installation, unzip all the files in the compression package of PHP DEBUG tools to the website publishing directory.
(Assuming the publication directory is c:\www, then create a new debug directory, throw all the files in)

Enter in Browser: http://localhost/debug/test1-debug.php
If you see the following illustration, the installation is successful.

two. Debug Article
1.Debug errors
such as the following code:
Copy Code code as follows:

<?php
Require './lib/debug.php ';
function test ($a, $b)
{
Echo $ASD;
}
Test (' abc ');
?>


2. Debug with Debug ()
such as the following code:
Copy Code code 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. Use Dump () or dump_tofile () debugging
such as the following code:
Copy Code code 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 ();
?>


As for Dump_tofile () it is generally used in the following situations:
A. When you don't want to stop the program running
B. Not that you don't want to display the modal data, but you can't. For example, when you are in the AJAX request state.
C. You still want to be in a lot of local mode

See test7-dump_tofile.php in the Debug directory

Note: When I run dump () or dump_tofile () I find that the PHP DEBUG tool document is not present

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 change one place.
At 149 lines.
Echo $pre;

Modified into:

Edit by Benben---start
Echo ' <script type= ' text/javascript ' > ';
Echo ' document.write (';
Echo $pre;
Echo ');
Echo ' </script> ';
Edit by Benben---End

Revised figure:

4. Tracking code, viewing system performance
You can browse the test3-trace.php in the directory, and then click on the lower right corner of the console.
You can refer to the document specifically. (The document is in the Doc directory in the compressed package)
three, how to combine with the project?

First of all, the PHP Debug tool extract file, placed in the project directory, build a directory called Debug! : )
In fact, we need only a few documents.
For example, the path is: C:\www\projectName\debug

After that, we can debug it in two different ways.
First, you can add a phrase to the project source code:
Include_once ('./lib/debug.php ');

For example, the following: c:\www\projectName\hellodebug\index.php
Copy Code code as follows:

<?php
Include_once ('./debug/lib/debug.php ');

$faint = ' HelloWorld, debuging ';

Debug ($ARRB);
?>


What, you don't want to write that on every page?
So look at the second method,
There are two ways to do this,
1. Modify PHP.ini to add the following content (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: I haven't tried this method, hehe)
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 will facilitate the commissioning of the entire project.

If it is the development of Ajax, there is a need, please refer to the document. (because I have not that need, so temporarily first jumped open, do not shoot bricks, hey hei.)

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.