Php debug debugging tool

Source: Internet
Author: User
Tags php debug

Its project address: php tutorial-debug-tools/"> 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:
Copy the Code 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 the 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. debug with dump () or dump_tofile ()
Run the following code:
Copy the 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 ();
?>


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/Webpage effect"> ';
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: wwwprojectnamedebug.

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: wwwprojectnamehellodebugindex. php
Copy the Code 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: wwwprojectnamedebugauto_prepend.php"
Auto_append_file = "c: wwwprojectnamedebugauto_append.php"

2. Modify the. htaccess file (Note: This method has never been tried,)
Php_value auto_prepend_file "c: wwwprojectnamedebugauto_prepend.php"
Php_value auto_append_file "c: wwwprojectnamedebugauto_append.php"

Related Article

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.