Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHPBuilder.com:
Implementing User Defined Interfaces in PHP 5
Aug 16, 2012 @ 13:35:53

On PHPBuilder.com today there's a new tutorial that talks about creating interfaces in PHP and how to use them to effectively structure your application.

Starting with PHP 5 the object model was rewritten to add features and bring PHP in line with languages such as Java and Visual Basic .NET. In this article I'll discuss interfaces, which is among the most important features in PHP 5. Other important features include abstract and final classes, methods and additional magic methods. You will learn how to define your own interfaces and how to work with them using different object model mechanisms.

The introduce you to some of the basic concepts behind using interfaces and how to create a basic one - a simple definition of a string class with one method, "getString". They then show how to extend a different example (a RandomNumber interface) and add on an additional method. He also shows how to extend multiple interfaces and integrate functionality from multiple sources, overloading and overrides.

tagged: user defined interface php5 tutorial extend implement

Link:

Bjarte Karlsen's Blog:
Sorting with uasort
Oct 30, 2006 @ 19:25:00

Bjarte Karlsen has a handy tip posted to his blog today - one array function to keep in mind when doing more than just the basic sorting - uasort.

Problem: You have an array of objects or a multidimentional arrays where the key of the first array has some meaning. It could be a id or something else. You want to sort the array and maintain the key=>value association.

Some may then proceed to loop the array and sort it in a loop, however there is a easier method.

He reminds us that the fucntion allows you to take in the array and, based on a user-defined function, sort the results, keeping the association between the keys and values.

tagged: sorting uasort user defined function maintian assoication sorting uasort user defined function maintian assoication

Link:

Bjarte Karlsen's Blog:
Sorting with uasort
Oct 30, 2006 @ 19:25:00

Bjarte Karlsen has a handy tip posted to his blog today - one array function to keep in mind when doing more than just the basic sorting - uasort.

Problem: You have an array of objects or a multidimentional arrays where the key of the first array has some meaning. It could be a id or something else. You want to sort the array and maintain the key=>value association.

Some may then proceed to loop the array and sort it in a loop, however there is a easier method.

He reminds us that the fucntion allows you to take in the array and, based on a user-defined function, sort the results, keeping the association between the keys and values.

tagged: sorting uasort user defined function maintian assoication sorting uasort user defined function maintian assoication

Link:


Trending Topics: