Home Backend Development PHP Tutorial PHP debugging tools Debug Tools_PHP tutorial

PHP debugging tools Debug Tools_PHP tutorial

Jul 21, 2016 pm 03:30 PM
debug php tools indivual Discover good tool Source code of debug

I found a good comrade who can debug PHP source code: PHP DEBUG TOOLS

Its project address: http://freshmeat.net/projects/php-debug-tools/
File download address: http:// freshmeat.net/urls/7c58ae3fecce5763e7546b958d36e082
It is currently version 1.03


The environment here is WINDOW XP, APACHE2.2, PHP5.2+ Zend Optimizer,
This is combined with PHP DEBUG TOOLS Help document to explain, some pictures are excerpted from the document.

1. Installation
Preparation environment before installation: 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 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 paragraph:
-- ----------I am the dividing line of perversion, 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
-------------This is a perverted dividing line, you can’t see me------- ------------------
Note: This example is for non-thread safe version. For the thread safe version change "zend_extension" to "zend_extension_ts"

After the installation is complete, unzip all the files in the PHP DEBUG TOOLS compressed package to the website release directory.
(Assume the release directory is c:www, then create a new debug directory in it and throw all the files into it)

Enter in the browser: http://localhost/debug/test1-debug.php
If you see the picture below, the installation is successful.
PHP debugging tools Debug Tools_PHP tutorial
2. Debugging
1.Debug errors
For example, the following code:

Copy code The code is as follows:

require './lib/debug.php';
function test($a, $b)
{
echo $asd;
}
test(10, ' abc');
?>

PHP debugging tools Debug Tools_PHP tutorial
2. Use Debug() to debug
such as the following code:
Copy the 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'));
?>

PHP debugging tools Debug Tools_PHP tutorial
3. Use dump() or dump_tofile() to debug
such as the following code:
Copy 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();
?>

PHP debugging tools Debug Tools_PHP tutorial
As for dump_tofile(), it is generally used in the following situations:
A. When you don’t want to stop the program running
B. It’s not that you don’t want to display the debugging data, but that you can’t. For example, when When you request status in AJAX.
C. You also want to debug in multiple places

Please refer to test7-dump_tofile.php in the debug directory

Note: I am running dump( ) or dump_tofile(), it is found that the
PHP debugging tools Debug Tools_PHP tutorial
mentioned in the PHP DEBUG TOOL document does not appear. This can be corrected by modifying the code of debug/lib/debug.php. (Because dump_tofile() has been called dump(), so we only need to modify one place.

echo $pre at line 149;

is modified to:

//edit by benben--- start
echo '';
//edit by benben---end

Corrected picture:
PHP debugging tools Debug Tools_PHP tutorial
4. Track the code, view System performance
You can browse test3-trace.php in the directory, and then click the console in the lower right corner.
For details, please refer to the documentation. (The documentation is in the doc directory in the compressed package)
3. How to integrate it with the project?

First, unzip the php debug tool file and place it in the project directory. Create a directory and call it debug! : )
Actually All we need is a few files.
For example, the path is: c:wwwprojectNamedebug

After that, we can debug in two ways
The first one is to add this sentence to the project source code :
include_once('./lib/debug.php');

For example: c:wwwprojectNamehellodebugindex.php
Copy code The code is as follows:

include_once('./debug/lib/debug.php');

$faint = 'helloworld ,debuging';

debug($arrb);
?>


What? You don’t want to write this sentence on every page?
Then look at the second one method,
There are two methods here,
1. Modify php.ini and add the following content (modify to your own directory):
auto_prepend_file = "c:wwwprojectNamedebugauto_prepend.php"
auto_append_file = "c:wwwprojectNamedebugauto_append.php"

2. Modify the .htaccess file (note: I have never tried this method, hehe)
php_value auto_prepend_file "c:wwwprojectNamedebugauto_prepend.php"
php_value auto_append_file "c :wwwprojectNamedebugauto_append.php"

This will facilitate the debugging of the entire project.

If it is AJAX development, there are still necessary places, please refer to the document for details. (Because I don’t have that yet. It’s necessary, so I’ll skip it for now and don’t make a fool of myself, hehe.)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323238.htmlTechArticleI found a good comrade who debugs PHP source code: PHP DEBUG TOOLS Its project address: http://freshmeat.net /projects/php-debug-tools/ File download address: http://freshmeat.net/urls/7c58ae3fecce57...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

How to ensure high availability of MongoDB on Debian How to ensure high availability of MongoDB on Debian Apr 02, 2025 am 07:21 AM

This article describes how to build a highly available MongoDB database on a Debian system. We will explore multiple ways to ensure data security and services continue to operate. Key strategy: ReplicaSet: ReplicaSet: Use replicasets to achieve data redundancy and automatic failover. When a master node fails, the replica set will automatically elect a new master node to ensure the continuous availability of the service. Data backup and recovery: Regularly use the mongodump command to backup the database and formulate effective recovery strategies to deal with the risk of data loss. Monitoring and Alarms: Deploy monitoring tools (such as Prometheus, Grafana) to monitor the running status of MongoDB in real time, and

PostgreSQL monitoring method under Debian PostgreSQL monitoring method under Debian Apr 02, 2025 am 07:27 AM

This article introduces a variety of methods and tools to monitor PostgreSQL databases under the Debian system, helping you to fully grasp database performance monitoring. 1. Use PostgreSQL to build-in monitoring view PostgreSQL itself provides multiple views for monitoring database activities: pg_stat_activity: displays database activities in real time, including connections, queries, transactions and other information. pg_stat_replication: Monitors replication status, especially suitable for stream replication clusters. pg_stat_database: Provides database statistics, such as database size, transaction commit/rollback times and other key indicators. 2. Use log analysis tool pgBadg

Can the Python interpreter be deleted in Linux system? Can the Python interpreter be deleted in Linux system? Apr 02, 2025 am 07:00 AM

Regarding the problem of removing the Python interpreter that comes with Linux systems, many Linux distributions will preinstall the Python interpreter when installed, and it does not use the package manager...

How to teach computer novice programming basics in project and problem-driven methods within 10 hours? How to teach computer novice programming basics in project and problem-driven methods within 10 hours? Apr 02, 2025 am 07:18 AM

How to teach computer novice programming basics within 10 hours? If you only have 10 hours to teach computer novice some programming knowledge, what would you choose to teach...

What is the impact of Debian Message on network configuration What is the impact of Debian Message on network configuration Apr 02, 2025 am 07:51 AM

The network configuration of the Debian system is mainly implemented through the /etc/network/interfaces file, which defines network interface parameters, such as IP address, gateway, and DNS server. Debian systems usually use ifup and ifdown commands to start and stop network interfaces. By modifying the ifeline in the interfaces file, you can set a static IP or use DHCP to dynamically obtain the IP address. It should be noted that Debian12 and subsequent versions no longer use NetworkManager by default, so other command-line tools, such as IP commands, may be required to manage network interfaces. You can edit /etc/netwo

How to get news data bypassing Investing.com's anti-crawler mechanism? How to get news data bypassing Investing.com's anti-crawler mechanism? Apr 02, 2025 am 07:03 AM

Understanding the anti-crawling strategy of Investing.com Many people often try to crawl news data from Investing.com (https://cn.investing.com/news/latest-news)...

How to solve the problem of Pylance type detection of custom decorators in Python? How to solve the problem of Pylance type detection of custom decorators in Python? Apr 02, 2025 am 06:42 AM

Pylance type detection problem solution when using custom decorator In Python programming, decorator is a powerful tool that can be used to add rows...

See all articles