Tag: PHP

Control Flow Keywords in PHP Loops

Too frequently I see PHP code that treats looping constructs (e.g. for, foreach, while) like runaway trains. Terminal conditions are set before entering the loop, but once the loop is started, it’s all hands off until it finishes. Unless there is an express need to iterate over every value, control flow keywords should be used [...]

View Comments  |  Permalink

Bending PHP, Control Flow Flexibility With call_user_func()

In comparison to other dynamic languages like Python and Ruby, control flow mechanisms in PHP are rigid. But in the absence of first-class functions and limited OOP paradigms, there’s still some flexibility in the language thanks to built in functions like call_user_func(). While lacking the same syntactic sugar, call_user_func() is the equivalent of variable variables($$v) [...]

View Comments  |  Permalink

PHP 5.3 Nowdoc Support

One of the missing things from PHP was the ability to have a multiline quote without evaluation. Sure, PHP came close with single quote marks ‘, but they required escaping. Heredoc syntax was a close second, but at minimum require escaping dollar signs $. Even output buffers, as phenomenal as a tool as they are, [...]

View Comments  |  Permalink

Thoughts on the Feasibility of Batch Jobs in PHP

I accept that every programming language is an exercise in trade-offs. In order to do certain things well, they inherently have to do some things poorly. The modestly low defaults for memory size and execution time limits in PHP are there for good reason. The language isn’t great at long executing memory intensive jobs. Offloading [...]

View Comments  |  Permalink

Link, a Simple URL Expander

As a fan of URL shorteners, my enthusiasm is tempered by the inherent security concerns. And rightfully so, I mean who knows what gruesome site is lurking behind that innocent bit.ly link? Over time I’ve adopted a very non-scientific, gut decision litmus test: if the source is legitimate and context looks good I click the [...]

View Comments  |  Permalink