Monthly Archives: June 2011

Standard PHP Library

Make objects iterable and countable using the SPL, part 1

Since its 5th version, PHP brings a full object model and offers a lot of features for OOP (Object-oriented programming). Unlike PHP 4, PHP 5 implements concepts such as visibility (public, private, protected), abstract classes and methods, interfaces... Moreover, it provides ...

calendar

Get the number of days in a month

Ever wonder how many days there are in a specific month ? Your quest is over, I have what you need : the cal_days_in_month() function from the Calendar PHP extension. This function can work with different calendars : gregorian, julian, jewish... ...

php+filter

Validate and sanitize data with PHP Filter, part 1

When coding websites or web applications, working on security is important. To prevent all kinds of injections (XSS, SQL, CSRF...), you have to check all data coming from a foreign source. The typical example is when a user send data ...

strings+array

Easy string to array conversion

As you may know, in the C language a string is in fact an array of characters, terminated by the null character \0. In PHP, the idea is still here but it's a little bit different. Strings are not considered as ...

sessions+performance

Speed up your sessions, part 1 – Best practices

This entry is the first part of two posts which will cover session performance in PHP, in a software point of view. So today, you will learn what to do and not do with sessions and how to optimize their setup ...