How to Debug php ""

Source: Internet
Author: User
Tags php debugging tools php website
Debugging a good code debugger in php "go" allows you to get twice the result with half the effort in solving the problem, because the code debugger can set breakpoints and track code lines by line, you can view the value of a variable and other advantages. Every development language has a good code debugger, and PHP is no exception. Xdebug and ZendDebugger are all very good php debugging tools, this article will show you how to use ecl to Debug php ""

A good code debugger can help you solve problems with half the effort, because the code debugger can set breakpoints, trace code line by line, and view variable values. Every development language has a good code Debugger, and PHP is no exception. Xdebug and Zend Debugger are all very good php debugging tools, this article will show you how to use eclipse + pdt + xdebug to Debug php websites.

?

1. prepare the tool

?

Eclipse, software developers on Earth know that they can use it to develop java projects. In fact, they can also use it to develop php websites. Click here to download the eclipse version integrated with pdt. Select the OS to download.

Php + apache, the two tools only need to install xampp that combines apache, php, mysql, and phpMyAdmin. if you do not know how to install and use xampp, read "How to install xampp" and "how to install and deploy a php website".

Xdebug: If you are using xampp, you do not need to download xdebug because it has been integrated. you only need to enable xdebug in the php. ini file of xampp. If you do not use xampp, you must select xdebug that suits your php version. Otherwise, the integration will fail. how do you know the version of xdebug to be downloaded? First, create a php file with the code , And then deploy it to php to run, view the relevant php information, copy all information to the xdebug official analysis tool page for analysis, it will give your php corresponding analysis results, you are prompted to download the corresponding version of xdebug.

?

2. configure eclipse pdt

?

Download eclipse for php developers and decompress it to use it. after the eclipse tool is opened, you can configure php and xdebug related information.

Window-> Preferences-> php,

How to call php website 1

Configure php to run the program first

How to call php website 2

Configure the runtime environment

How to call php website 3

Select php version

How to call php website 4

Configuration Server

How to call php website 5

Configure xdebug

How to call php website 6

?

3. configure php and integrate xdebug

?

If you have not installed xampp, you need to first download the xdebug file corresponding to the php version you have installed. the specific practices are described in the tool preparation section at the first step, if you have installed xampp, congratulations. you only need to enable xdebug. ini, search for Xdebug, find zend_extension, and delete zend_extension. change the path on the right of "=" to "D: \ xampp \ php \ ext \ php_xdebug.dll". (note: path to the directory you installed), and then remove the following options, and change the value on the right of the = to be consistent with the following

Xdebug. remote_enable = On

Xdebug. remote_host = "localhost". note: The localhost here is changed to the IP address of your server.

Xdebug. remote_port = 9000

Xdebug. remote_handler = "dbgp"

?

4. configure apache

?

By configuring the apache server, you can map the access path to your local php website Program Directory. if you have installed xampp, you only need to modify the httpd-xampp.conf file under the apache \ conf \ extra directory, in Add the following code to the tag:

Alias/phpip "D:/phpworkspace/HelloWorld /"

Options Indexes FollowSymLinks between Des ExecCGI

AllowOverride all Order allow, deny

Allow from all

Change/phpip to the project name in the browser, and change D:/phpworkspace/HelloWorld/to the corresponding directory of your program.

?

5. set breakpoint and debug

?

Set a php debugging breakpoint in eclipse, and then enter "http: // servername/phpname/debugging file" in the browser to access it. servername is the address of your server, phpname is the php project name you set in apache. Eclipse will prompt whether to open the debugging control panel, such:

How to Debug php website 7

Next, you can debug the code line by line.

How to Debug php website 8

On the Debug output panel, you can view the browser output.

How to Debug php website 9

Actual webpage access results

How to Debug php website 10

Now, you have learned how to Debug php. Try it now.

?

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.