Home arrow PHP arrow Using Conditional Statements with the Xdebug Extension

Using Conditional Statements with the Xdebug Extension

In this fifth part of a series on using the Xdebug extension to help debug your PHP programs, we'll take a closer look at the xdebug_start_code_coverage() and xdebug_get_code_coverage() functions. Specifically, we'll see how we can extend their usage when working with conditional statements. As always, we'll complement theory with a number of hands-on examples.

TABLE OF CONTENTS:
  1. Using Conditional Statements with the Xdebug Extension
  2. Review: the xdebug_start_code_coverage() and xdebug_get_code_coverage() functions
  3. Extending the xdebug_start_code_coverage() and xdebug_get_code_coverage() functions
  4. Debugging conditionals with the xdebug_start_code_coverage() and xdebug_get_code_coverage() functions
By: Alejandro Gervasio
Rating: starstarstarstarstar / 2
March 02, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

Debugging a PHP application can be a challenging task, particularly when itís necessary to evaluate the more complex facets of a program. By these I mean which functions are called by it, in what order, or even the performance of its different modules.

In this situation, it's recommended that you use a third-party debugging library. You'll find a variety of these on the web these days. If youíre planning to pick up a package that lets you debug your PHP applications in a truly painless way, then you might want to take a closer look at the Xdebug extension. It's a friendly and powerful piece of software that will permit you to perform all sorts of debugging tasks, with minimal configuration requirements and an easy learning curve.

And speaking of debugging tasks, you'll probably recall that I left off the last article discussing the use of the xdebug_start_code_coverage() and xdebug_get_code_coverage() functions, which came in handy for keeping track of which lines are executed by a targeted PHP application.

Speaking more specifically, in that tutorial I demonstrated how to utilize these functions to determine the execution flow of a simple script that created an instance of a sample class, and then called some of its methods. However, itís much more interesting to use these functions to check the flow of a program when working with conditional statements.

Undoubtedly, determining what code block is executed by an application, based on certain conditions, is a task that programmers have to face on a frequent basis, and the less effort this process involves, the better. Thus, provided that youíre interested in learning how to employ the xdebug_start_code_coverage() and xdebug_get_code_coverage() functions to debug conditional statements within a PHP program, in this fifth part of the series Iíll be coding for you some illustrative examples that will show you how to perform this debugging procedure in an approachable fashion.

Now, letís get rid of the preliminaries and start learning how to use the X-debug extension to work with conditionals in PHP. Letís jump in!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: