Home > php教程 > php手册 > body text

How to debug PHP XDebug

WBOY
Release: 2016-07-09 09:10:19
Original
1148 people have browsed it

PHP debugging has always been a problem for me. I have been using echo and var_dump pile driving modes before, and the efficiency is very poor. This time I decided to study how to debug PHP. By the way, I wrote down the steps to strengthen my memory and also provide For everyone’s reference.

First, let’s talk about how to use XDebug to debug PHP programs.

My development environment:

1, Eclipse PDT (Eclipse IDE for PHP Developers 1.3.0.20100617-0520), I prefer Eclipse as this IDE, it is more powerful. There are also many plug-ins

2, XAMPP version 1.7.4 (Apache 2.2.17, MySQL 5.5.8 (Community Server), PHP 5.3.5 (VC6 X86 32bit) PEAR), XAMPP is very convenient to use, I I am too lazy to configure it myself . In addition, I downloaded the ZIP version, which is mainly for program development and debugging

3, XDebug. This is already included in the PHP package of XAMPP. If you want to download it yourself, you can Go to the xdebug website, but be aware that XDebug requires PHP version, compiler, and whether it is 32Bit or 64bit

4, system Windows 7

Configure PHP.ini

PHP.ini is located under xamppphp. Let’s edit this file first, find the [XDebug] node in it, and remove the configuration comments (what I use here It is PHP5.3.5 that comes with XAMPP. This node may not have been in PHP.ini before):

[xdebug]
; zend_extension is the address of the php_xdebug.dl file
zend_extension = ".extphp_xdebug.dll"

;remote_enable allows XDebug to support debug client
xdebug.remote_enable = 1

;Host address
xdebug_remote_host = "localhost"

;Debug port
xdebug.remote_port = 9000

;Debug protocol
xdebug.remote_handler = "dbgp"

In addition, it should be noted that eclipse does not seem to recognize directory writing methods like "xamppphpext". I changed them here to ".ext"

Configuring Eclipse PDT

First add PHP Executestables in Windows Preferences As shown below

How to debug PHP XDebug

Modify RunDebug Configuration, select XDebug for PHP Debugger, select the one we just filled in for PHP Executables, and PHP File is the file to prepare for Debug:

How to debug PHP XDebug

Next, we write a test program

Add a PHP Project in Eclipse and add a simple php file, such as debug.php:

debug.php

<?php
Copy after login
    $a = 1;
Copy after login
    $b = 2;
Copy after login
    $c = $a + $b;
Copy after login
    echo $c;    
Copy after login
?>
Copy after login

And write this file to the PHP file in Debug Confiugration. You can refer to the Configuring Eclipse PDT->Modify RunDebug Configuration.

Then you can debug, as shown below:

How to debug PHP XDebug

The above is the most basic PHP script debugging method, for reference only. Note that what is being debugged here is PHP Script, which is debugging in command line mode. I will explain how to use Web Site to debug PHP page files in a future blog, so stay tuned

source:php.cn
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!