Pebble – more injection and less dependencies in PHP

Dependency Injection (DI) is hardly anything new. I see it as a must for Test Driven Development (TDD). The thing I like most about DI in Java is Autowired in Spring or javax.annotation.Resource, they way member variables are set “magically” and the exact details about creation and implementation is located elsewhere. For PHP there are… Continue reading Pebble – more injection and less dependencies in PHP

fmod() in PHP is the worst !”#¤%&/()= function ever!

I hate floating point artithmetic and I really hate fmod() in PHP. It’s useless. fmod — Returns the floating point remainder (modulo) of the division of the arguments If you calculate 36 modulo 7.2?  What do you get? Zero, yes. 7.2*5=36. No remainder! What if you use fmod in PHP? $ php -r ‘echo fmod(36,7.2);’… Continue reading fmod() in PHP is the worst !”#¤%&/()= function ever!

Today’s thoughts about programming languages

Maybe some of you have heard me ranting about this already? I’m not productive enough in C++ and I feel too limited by Java A large chunk of Java frameworks seem to serve no other purpose than to workaround limitations in Java I believe (and hope!) that Java will cease to be the default language… Continue reading Today’s thoughts about programming languages

Permute an array in PHP

I wrote this function recently when I could not find it in the PHP function list. Please provide any optimizations you discover! function permute($array) { $results = array(); if (count($array) == 1) { $results[] = $array; } else { for ($i = 0; $i < count($array); $i++) { $first = array_shift($array); $subresults = permute($array); array_push($array,… Continue reading Permute an array in PHP

WordPress crack attempt this morning!

When I got to work and viewed this blog I noticed that Sidebar Widgets was disabled. I thought "That’s weird!" When I tried to login to the administration interface I was told that my WordPress database needed upgrading. I thought "That’s weird!" Some further investigation revealed that someone managed to upload a PHP script called… Continue reading WordPress crack attempt this morning!

Andi Gutmans: “Java is losing the battle for the modern Web”

Andi Gutmans (of PHP fame) has written a very interesting blog post about Java’s future on the web. The article is called Java is losing the battle for the modern Web. Can the JVM save the vendors? He gives some good arguments for using a LAMP stack for web applications. One of the interesting quotes… Continue reading Andi Gutmans: “Java is losing the battle for the modern Web”

MySQL support for UTF-8 in PHP

Originally published in Swedish in my Folkmun.se Blog, a handy tip to make sure that you are reading and writing UTF-8 when connecting to a MySQL database: mysql_query(“SET NAMES utf8”); mysql_query(“SET CHARACTER SET utf8”)