Featured Posts

Writing Website Scrapers in PHPWriting Website Scrapers in PHP This article discusses about how to write a website scraper using PHP for web site data extraction. The concepts taught can be applied and programmed in Java, C#, etc. Basically any language that has a...

Readmore

12 common programming mistakes to avoid12 common programming mistakes to avoid 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...

Readmore

7 habits of highly effective freelance programmers7 habits of highly effective freelance programmers I have developed these based on my freelancing experience. Though I have discontinued freelancing, but would like to share my practices with you. These are basic practices and have been developed over...

Readmore

  • Prev
  • Next

PHP5 Tutorial - instanceOf Operator Explained

Posted on : 15-11-2007 | By : admin | In : PHP, PHP Tutorials, PHP5 OOPS Tutorials

1

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.

PHP5 Tutorial - $this variable explained

Posted on : 14-11-2007 | By : admin | In : PHP, PHP Tutorials, PHP5 OOPS Tutorials

4

$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.

PHP Script to Extract Email Address from any text

Posted on : 14-11-2007 | By : admin | In : PHP, PHP Code Examples, Programming

6

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.

Stack Implementation in PHP5 - Stack Class

Posted on : 14-11-2007 | By : admin | In : PHP, PHP Class Examples, PHP Tutorials

1

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

PHP5 Tutorial - Function - Method Type Hinting in PHP5

Posted on : 14-11-2007 | By : admin | In : PHP, PHP Tutorials, PHP5 OOPS Tutorials

1

PHP5 Introduces Method Type Hinting. Type Hinting allows a function to force parameters to be objects of a particular class by specifying the name of the class in the function prototype.

Type Hinting is optional in all cases except catch block.

PHP5 Tutorial OOPS - PHP5 Class Access Specifiers - public, private and protected

Posted on : 14-11-2007 | By : admin | In : PHP, PHP Tutorials, PHP5 OOPS Tutorials

29

In the earlier tutorials we have witnessed keywords like public, private and protected. These are nothing but access specifiers. So, lets understand what access specifiers are.

Definition of Access Specifiers
Access specifiers specify the level of access that the outside world (i.e. other class objects, external functions and global level code) have on the class methods and class data members. Access specifiers can either be public, private or protected.

PHP5 Tutorial OOPS - Creating a PHP5 Destructor __destruct()

Posted on : 14-11-2007 | By : admin | In : PHP, PHP Tutorials, PHP5 OOPS Tutorials

2

Definition of a Destructor
A destructor is a special function of a class that is automatically executed whenever an object of a class is destroyed.

What does this all mean?
Let’s revisit that definition in more simple terms. A destructor is a special function - this means that a destructor is a function; but its special. But, why is it special? It’s special because it is automatically executed or called when an object of a class is destroyed. An object of a class is destroyed when

  1. it goes out of scope,
  2. when you specifically set it to null,
  3. when you unset it or when the program execution is over.

PHP5 Tutorial - Creating a PHP5 Constructor __construct()

Posted on : 14-11-2007 | By : admin | In : PHP, PHP Tutorials, PHP5 OOPS Tutorials

9

Definition of a Constructor
A constructor is a special function of a class that is automatically executed whenever an object of a class gets instantiated.

What does this all mean?
Lets revisit that definition in more simple terms. A constructor is a special function - this means that a constructor is a function; but its special. But, why is it special? It’s special because it is automatically executed or called when an object of a class is created.

PHP5 Tutorial - Defining Methods of a PHP5 Class

Posted on : 08-11-2007 | By : admin | In : PHP, PHP Tutorials, PHP5 OOPS Tutorials

8

In this PHP5 tutorial you will learn about methods and how to declare and use them in PHP5 class.

Definition of an class method
A class method/functions is the behavior/functionality of a class i.e. they provide the necessary code for the class in which it is defined. Examples could be a saveCustomer() method in the class Customer or a printDocument() in the Document class.

Methods act (perform operations) on the data members of the class and can be declared as private or public. A class method is exactly similar to PHP functions, it’s just that class functions are declared inside classes and accessed using the -> (arrow operator / dereferencing operator).

PHP5 Tutorial - Defining Attributes of a PHP5 Class

Posted on : 08-11-2007 | By : admin | In : PHP, PHP Tutorials, PHP5 OOPS Tutorials

11

In this tutorial you will learn about class attributes and how to declare & use them in PHP5 classes.

Definition of an class attribute
An attribute is also know as data members and is used to hold data of a class. The data that it holds are specific to the nature of the class in which it has been defined. For example, a Customer class would hold data related to a customer, an Order class would hold data related a an order.