PHPNews

Words escape me

Look, I know this is going to be tough to read, and I usually try to post short, snappy code snippets, but this is just too good. Or sad. Whatever. Words truly escape me. Take it away anonymous submitter: “Look at all these standalone ternaries for validating form input. What a mess! They’re embedded in what …

Continue reading »

Written by CSI: PHP - - Aggregated on Friday October 12, 2012


Silex Controllers as Services

**UPDATE**: The functionality described below is now baked in to Silex, checkout the [ServiceControllerServiceProvider](http://silex.sensiolabs.org/doc/providers/service_controller.html). **TL;DR** Use a custom controller resolver to load controllers from the service container - [code][code] I'll …

Continue reading »

Written by Dave Marshall - - Aggregated on Wednesday October 3, 2012


Too few DEFINEs for my taste

The Crime It takes a big man to admit when he’s wrong, and @dilbert4life is one of those men. Here’s a snippet of horror that he wrote around a year-and-a-half ago. Too many defines? Nay! I say let the site grow and see just how many we can stuff in there. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18…

Continue reading »

Written by CSI: PHP - - Aggregated on Friday September 28, 2012


What idiot wrote this? Oh, wait, it was me.

Starting with this post, we have a new category here at CSI: PHP. It’s called ‘ mea culpa ’, and it’s criminal code written by yours truly. Behold the awesome that is error() , an unholy concoction of PHP, JavaScript, and HTML. It’s the only function in a file called common.php, which makes perfect sense because …

Continue reading »

Written by CSI: PHP - - Aggregated on Friday September 21, 2012


Stop rolling your own

Seriously. Stop it. Or you’ll end up with garbage like this, in which a developer writes two separate functions for converting JSON to an array, only one of which is compatible with json_decode . Yes, both are in production. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 …

Continue reading »

Written by CSI: PHP - - Aggregated on Friday September 14, 2012


We don't need no stinkin' POST variables

CSI: PHP investigator Duane Gran sent in this horrifying snippet. He explains: I wondered why dumping the $_POST variables before this section didn’t help in debugging. This occurs in a second step of a 3-step form on a GET request. It applies a set of session fields to the $_POST variable for later use. …

Continue reading »

Written by CSI: PHP - - Aggregated on Friday September 7, 2012


Why Symfony?

Yesterday, Zend Framework 2.0 and Symfony 2.1 were released... almost at the same time. First, I want to congratulate the Zend Framework team for this huge milestone; I know that working on a new major version is no small task. And of course, people started to ask questions about these new versions and one of the …

Continue reading »

Written by Fabien Potencier - - Aggregated on Friday September 7, 2012