PHP5 OOPS Tutorials – Polymorphism

February 11th, 2008 10 comments

In this tutorial we will learn the following:

  • Meaning of Polymorphism
  • Why method polymorphism cannot be achieved in PHP
  • PHP 5 Object Polymorphism

Read more…

PHP5 Tutorials – Abstract Class and Interface

February 3rd, 2008 8 comments

In this post, we learn what is an abstract class and an interface.

  • What is an Abstract Class?
  • Private methods cannot be Abstract
  • What is an Interface?
  • Defining an Interface
  • Abstract Class v/s Interface

Read more…

12 common programming mistakes to avoid

November 16th, 2007 13 comments

Programming is an art and science and like all art and science the only way to learn is from mistakes. I have made many… and I would like to share with you the mistakes that I have made over my journey with development.

Read more…

Categories: Programming Tags:

PHP Script to print nested array

November 16th, 2007 5 comments

Here is a script that will allow you to print a nested array upto any level. Can I request you to please review this and let me know how this can be further optimized.

Read more…

Categories: PHP, PHP Code Examples Tags:

PHP5 Tutorial – Inheritance in PHP5

November 15th, 2007 2 comments

In the tutorial we will understand what is Inheritance in general and how to inherit classes in PHP5.

Definition of Inheritance:

Inheritance is the mechanism of deriving a new class from an existing class. It allows a sub-class / child class to share/inherit the attributes and behaviors of a base-class or parent class. These inherited attributes and behaviors are usually modified by means of extension.

Read more…

Categories: PHP, PHP Tutorials, PHP5 OOPS Tutorials Tags:

PHP5 Tutorial – Defining Class Constants

November 15th, 2007 1 comment

In PHP4 the only constants that we would declare were global constants. In PHP5 it is possible to define a class level constant. These constants are specific to the class and hence don’t clutter the global level constant space.

Read more…

Categories: PHP, PHP Tutorials, PHP5 OOPS Tutorials Tags:

PHP5 Tutorial – instanceOf Operator Explained

November 15th, 2007 2 comments

PHP5 introduces a new operator by the name of instanceOf. instanceOf is used to check if two objects passed as operands belong to the same class. This check can also happen when an object is compared with a class name.

In PHP4 a similar functionality existed with a method is_a(), which has been replaced by the instanceOf operator in PHP5.

Read more…

Categories: PHP, PHP Tutorials, PHP5 OOPS Tutorials Tags:

PHP5 Tutorial – $this variable explained

November 14th, 2007 4 comments

$this variable is a pointer to the object making the function call. $this variable is not avialable in static methods. We will learn more about static methods in the next series of tutorials.

Read more…

Categories: PHP, PHP Tutorials, PHP5 OOPS Tutorials Tags:

PHP Script to Extract Email Address from any text

November 14th, 2007 6 comments

I have developed a function that you can embed in your PHP applications that will help you extract email addresses from a given piece of text.

I have tested this on a string of (actually 4 – 5 paragraphs) text and this has performed very well.

Please feel free to use this code in your applications and let me know if you face any issues.

Read more…

Categories: PHP, PHP Code Examples, Programming Tags:

Stack Implementation in PHP5 – Stack Class

November 14th, 2007 1 comment

Refer to the code below which is a PHP5 Stack Class – an implementation of Stacks. You are free to use it in your programs.

Read more…

Categories: PHP, PHP Class Examples, PHP Tutorials Tags: