Php: page 2
PHP date localisation with setlocale
Localising sites can be a chore, but PHP has the venerable setlocale() to use system locales. These are like templates or profiles that describe how various types of data should be displayed. Should a price have a comma or point to indicate the decimals? When printing a date should PHP output Monday or Montag? All of these considerations are locale specific and they map to a geographical area. Various cultures have their own standards for displaying this kind of information not to mention different languages to accommodate. Read more ⇒
Simultaneously benchmark many URLs with ApacheBench and GNU parallel
Once in a while you come across situations where someone wants to know what a server can do or how many requests it can handle under a realistic load scenario. It could simply be that you want to hit a large selection of sites or even that you want to simultaneously hit a number of different pages on the same site. In my case I am testing the performance of a Drupal multisite installation where one core set of code is shared by many sites on different URLs. Read more ⇒
A little known feature of PHP’s static keyword is that it allows for memoization or function caching. This is a process whereby a functions heavy lifting can be cached so that subsequent calls are faster. It is possible to store any value in a memoized way such as arrays or even objects. This is done without any external side effects - that is to say that the code calling the function will require no changes to support memoization. Read more ⇒
It is possible to treat a class instance as a function in PHP. Quite often this is referred to as a functor even though it should really be known as a function object. This is because functions actually serve a different role in languages that support their use. The convenience of having a reusable function that can be overloaded and carry a context is something to weigh up against using functions or closures. Read more ⇒
Functional Programming in PHP - The book
After working hard on the guide to Functional Programming in PHP I am pleased to announce that it has been published by php[architect]! The book is offcially now available and you can purchase your very own copy! If you’re a programmer who wants less bugs and easier testing then this is the functional introduction for you. Throughout the chapters I gently lead you through the various functional constructs available in and with PHP. Read more ⇒
Functional Programming on Three Devs and a Maybe
I was recently invited to join Edd and Michael to appear on the Three Devs and a Maybe podcast to discuss function programming. The recording of our chat is now available so head on over and have a listen. If you haven’t listened to the podcast before there are some 34 past episodes archived there as well! note If you are interested in finding out more about my book on functional programming in PHP or to subscribe for notification of its release please visit functionalphp. Read more ⇒
HHVM vs Zephir vs PHP: The showdown
Since its inception the slow running speed of PHP has been widely publicised and over the years there have been a number of improvements. The first Zend Engine arrived with PHP4 and delivered various performance enhancements (among other features). Each release since this time has delivered some sort of increased efficiency in one way or another. It has become more interesting recently however with three projects looking for improvements in different ways. Read more ⇒
I was recently invited to speak about functional programming in PHP for both BrightonPHP and PHP Hampshire. The details of which are in a previous blog post. If you attended either talk and you’ve yet to leave feedback then please do on the respective Joind.in pages: Brighton PHP joind.in page PHP Hampshire joind.in page You can view the slides from the sessions on my website. I created the slides using reveal. Read more ⇒
Speaking about Functional PHP at BrightonPHP and PHP Hampshire
I have been invited to speak at both the upcoming meetings of BrightonPHP and PHP Hampshire about functional programming. This is off the back of the site I created for my (soon to be released) book tentatively entitled Functional Programming in PHP. To get a better idea of what the talk will include I have prepared an abstract: In the PHP world functions are generally sneered at due to their simplicity and perceived as an evil side effect of spaghetti code. Read more ⇒
Add a duration or interval to a date
In PHP you can easily add a duration to a DateTime instance in a number of ways. I will review the most common methods for completing the task starting with those available on the DateTime object itself. If you are running PHP 5.2 then the only way to achieve this is to call the modify method. This allows you to pass in a date format, but in this case we are most interested in the relative formats. Read more ⇒