Monthly Archives: May 2011

Interfaces Abstract Classes and the Adapter Pattern

PHP 5 made significant improvements on the Object Orientated programming model of PHP 4 bringing it more in line with languages such as Visual Basic .NET and Java. The improved object model in PHP 5 makes developing applications using OOP much easier and gives you the programmer, greater flexibility. The first features new to PHP… Read More »

Category: PHP

Remove a Query String Key=>Value using PHP

I needed to find a PHP function that would allow me to remove keys (and their values) easily and reliably. /* the function */ function remove_querystring_var($url, $key) {   $url = preg_replace(‘/(.*)(?|&)’ . $key . ‘=[^&]+?(&)(.*)/i’, ‘$1$2$4’, $url . ‘&’);   $url = substr($url, 0, -1);   return $url; }

Category: PHP

The PHP Class with Dynamic Functions

class Record {     /* record information will be held in here */   private $info;     /* constructor */   function Record($record_array) {     $this->info = $record_array;   }     /* dynamic function server */   function __call($method,$arguments) {     $meth = $this->from_camel_case(substr($method,3,strlen($method)-3));     return array_key_exists($meth,$this->info) ? $this->info[$meth] : false;  … Read More »

Category: PHP

Php Writing to csv file

In this code am taking in a variable from a dynamic form($search). The variable is 10 random unique numbers. It was put into the form from a text/csv file. In this I need to write each line of the text/csv file into an array except the $search number, delete the contents of the file &… Read More »

Category: PHP

PHP Class Tutorial: Working with Methods

Class properties allow your objects to store data and class methods allow your objects to perform tasks. What are Class Methods Methods are special functions declared within a class. As you might expect, a method declaration resembles a function declaration. The function keyword precedes a method name, followed by an optional list of argument variables… Read More »

Category: PHP

PHP Exception Handling

What is an Exception With PHP 5 came a new object oriented way of dealing with errors. Exception handling is used to change the normal flow of the code execution if a specified error (exceptional) condition occurs. This condition is called an exception. This is what normally happens when an exception is triggered: The current… Read More »

Category: PHP

Introduction to PHP5 OOPS Features

PHP5 has made a lot of improvements as regarding OOPS is concerned. Although it has not been up to the mark with the likes of Java, .NET and C++; but when compared to PHP4, PHP5 has made significant improvements. In this post, I propose to cover the following topics: About PHP5 Future of PHP New… Read More »

Category: PHP