Home arrow PHP arrow Using Recursive Methods in Object-based PHP Applications

Using Recursive Methods in Object-based PHP Applications

Welcome to the second tutorial of the series “Recursion in PHP.” Comprised of three parts, this series introduces the fundamentals of recursion in PHP, including the definition and use of recursive functions in procedural PHP scripts, as well as the creation of recursive methods in object-oriented Web applications.

TABLE OF CONTENTS:
  1. Using Recursive Methods in Object-based PHP Applications
  2. Applying recursion in object-oriented programming: creating object-based web page elements
  3. Defining a recursive method: creating a web page generator class
  4. A final example of recursion: creating a template processor class
By: Alejandro Gervasio
Rating: starstarstarstarstar / 7
May 08, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

Just in case you don’t remember, in the first article of the series, I explored the basics of recursion, highlighting its benefits and drawbacks, in this way providing an in-depth explanation of how recursive functions work internally. To sustain the underlying theory, I showed numerous hands-on examples, which hopefully demonstrated that defining recursive functions to solve specific programming issues is not only easy, but also instructive and educational.

As I stated in the previous article, sometimes recursion can be used when writing functions and methods aimed at navigating tree structures or linked lists. Also, even when recursion is considered an advanced approach for addressing specific problems (instead of using traditional iteration), it should be utilized with caution. It introduces significant overhead in server memory, and eventually can slow down certain applications.

Now, in this second part of the series, I’ll explore some advanced uses of recursion in PHP, particularly in the terrain of object-oriented programming. I will develop a couple of object-based applications which use recursive methods for accomplishing their tasks. By the end of this tutorial, you should have a pretty solid grounding in how to define recursive methods within your own PHP classes.

With the formalities out of the way, it’s time to leap forward and continue learning more about how to use recursion in PHP. Let’s go!



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

blog comments powered by Disqus
   

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

 



© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap

Dev Shed Tutorial Topics: