Using Xdebug to debug and optimize PHP programs [1]_php Tips

Source: Internet
Author: User
Tags php debugger
Author: Haohappy
Msn:haohappy at MSN.com
Blog: http://blog.csdn.net/haohappy2004
2006-07-04
why need Debugger?
Many PHP programmers debug using Echo, Print_r (), Var_dump (), printf (), and so on, but for programmers with richer development experience, they can often By outputting the value of a particular variable, you can tell whether the program is performing correctly, or even how efficient it can be (some time functions may be required, of course). So why do we need a special debugging program to monitor our program's operation? The answer to this question may well be left behind to reveal.
What is Xdebug?
Xdebug is an open source PHP debugger (a debug tool) that you can use to track, debug, and analyze the state of your PHP program. Xdebug's current version is Xdebug 2.0.0BETA6, which supports PHP4/PHP5.
Official site: www.Xdebug.org
How to install Xdebug ?
Take the Php5.1.4,windows platform as an example (other PHP version, other platforms please refer to the official website documentation):
1. Login www.xdebug.org, on the right side of the home page has a Windows modules, select which php5.1.2+, download Php_xdebug-5.1.2-2.0.0beta6.dll file;
2. Place the downloaded Php_xdebug-5.1.2-2.0.0beta6.dll in the C:\php5\ext directory and rename to Php_xdebug.dll;
3. Edit PHP.ini and add the following lines:
Extension=php_xdebug.dll
[Xdebug]
Xdebug.profiler_enable=on
Xdebug.trace_output_dir= "I:\Projects\xdebug"
Xdebug.profiler_output_dir= "I:\Projects\xdebug"
The following directory "I:\Projects\xdebug" for the directory where you want to place the Xdebug output data file, can be set freely.
4. Restart Apache;
5. Write a test.php, the content is <?php phpinfo ()?>, if you see xdebug in the content of the output, the installation configuration is successful.
now we can start using Xdebug powerful function of the!

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.