How to debug PHP "turn"

Source: Internet
Author: User
Tags php debug php debugging tools php website
How to debug PHP "turn"

A good code debugger allows you to do more with the problem, because the code debugger can set breakpoints, line-by-row code tracking, you can see the value of variables and so on. Every development language has a good code debugger, PHP is no exception, Xdebug, Zend debugger, etc. are very good PHP debugging tools, this article will show you how to use Eclipse+pdt+xdebug to debug PHP Web site.

?

1. Tool Preparation

?

Eclipse, the Earth's software developers know that it can be used to develop Java projects, in fact, it can also be used to develop PHP Web site, click here to download integrated PDT version of Eclipse. Select the downloads that apply to your operating system.

Php+apache, these two tools only need to install a set of Apache, PHP, MySQL, phpMyAdmin equals one xampp can, if you do not know how to install and use XAMPP, please read "How to install Xampp" and "How to install the deployment of PHP site."

Xdebug, if you are using XAMPP, then you do not need to download Xdebug, because it is already integrated, you only need to xampp php.ini file to open Xdebug on the line. If you do not use XAMPP, then you must choose the appropriate PHP version of the Xdebug, otherwise the integration is not successful, how to know what version of the xdebug to download? First of all, create a PHP file, the code is , then deploy to PHP to run, view php information, copy all the information to the Xdebug Official Analysis tool page for analysis, it will give your PHP corresponding analysis results, prompting you to download the corresponding version of the Xdebug.

?

2. Configure eclipse PDT

?

After you download the Eclipse for PHP developers, the decompression is ready to use, and after you open the Eclipse tool you can configure the information about PHP and Xdebug.

window->preferences->php,

How to call PHP Web site 1

Configure PHP to run the program first

How to call PHP Web site 2

Configuring the Operating Environment

How to call PHP Web site 3

Select PHP Version

How to call PHP Web site 4

Configure the server

How to call PHP Web site 5

Configure Xdebug

How to call PHP Web site 6

?

3. Configure PHP, integrated Xdebug

?

If you do not have XAMPP installed, then you need to download the xdebug you have with the version of PHP you installed, as described in the 1th tool preparation, if you have installed XAMPP, then congratulations, you only need to open xdebug on the line, The specific method is to open the php.ini, and then search Xdebug, find the zend_extension before, remove, the right of the = number of the path to "D:\xampp\php\ext\php_xdebug.dll", ( Note: The path to be modified for your own installation of the directory), and then put the following several options before, also removed, and the = number to the right of the value of the following match

Xdebug.remote_enable=on

xdebug.remote_host= "localhost", note: Here the localhost is changed to your server corresponding IP

xdebug.remote_port=9000

Xdebug.remote_handler= "DBGP"

?

4. Configure Apache

?

By configuring the Apache server can be implemented to map the access path to your local PHP site program directory, if you install XAMPP, then only need to modify the Apache\conf\extra directory httpd-xampp.conf files, Add the following code to the tag:

Alias/phpip "d:/phpworkspace/helloworld/"

Options Indexes FollowSymLinks includes execcgi

allowoverride all Order Allow,deny

Allow from all

Where/PHPIP changes to the name you want to enter in the browser to access the project, d:/phpworkspace/helloworld/changes to the directory that corresponds to your program.

?

5. Set breakpoints and debug

?

Set PHP debug breakpoints in Eclipse, then enter "http://servername/phpname/Debug Files" in the browser to access, ServerName is the address of your server, Phpname is the name of the PHP project you set up in Apache. Eclipse prompts you to open the Debug Control Panel, such as:

How to debug PHP website 7

You can then debug the code line by row

How to debug PHP website 8

You can also view the Web browsing output in the debug output panel

How to debug PHP website 9

Actual access to page results

How to debug PHP website 10

In this way, you have learned how to debug PHP, try it quickly.

?

Original address: http://www.laokboke.net/2011/05/09/how-to-debug-php-using-xdebug/

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