Archive for the ‘PHP’ Category

 

Fredrik Holmström on Nov 27th, 2008Did you loose your job to a geek 15 years younger than you?

Reading this article and then looking at the authors CV I’ve only got one question on my mind: “Did you loose your job to someone 15 years younger and with more experience then you Carl?”. Honestly I’ve got a better skill-set and done more programming then you and you seem to have at least 20 […]

Fredrik Holmström on Oct 26th, 2008Set sail for fail (php namespaces)

On this: http://news.php.net/php.internals/41374
ClassFile.php

namespace Foo;
class tBar {
function loader() {
}
}

Bootstrap.php

include “ClassFile.php”;
spl_autoload_register(array(”Foo\tBar”, “loader”));

Will register “Foo[tab]Bar::loader”. Yes there are workarounds such as \\ or ‘, but I thought that some of the requirements were:
typo-vulnerability (\ becomes even more - in a very bad way - context sensitive within strings)
parse-ability […]

Fredrik Holmström on Oct 2nd, 2008Good news, enhanced LSB support in PHP 5.3

Maybe this is old news, but I was playing around with latest PHP5.3-alpha today and found that this now works:
<?php
class Foo {
static function test() {
echo get_called_class();
}
}

class Bar extends Foo {
}

class Baz extends Foo {
static function test() {
echo Foo::test();
echo parent::test();
}
}

Foo::test();
Bar::test();
Baz::test();

It now correctly prints “FooBarFooBaz” when it previously would’ve printed “FooBarFooFoo” since the last time I tried […]

Fredrik Holmström on Sep 28th, 2008CakePHPs Set::extract reimplemented

After reading XPath on PHP Arrays (Set::extract), checking the source and trying it out I had a pressing feeling that the CakePHP solution is overly complex - so I sat out to re-implement it in lesser and leaner code, an hour or so later this is what I ended up with:
download set-v02.zip
The syntax isn’t pure […]

Fredrik Holmström on Sep 27th, 2008i18n with PHP and XML

This is a simple internationalization (henceforth i18n) library of 80 or so lines that I put together, I’m well aware that gettext plus numerous other i18n solutions already exist for PHP - but not everyone that is translating sites have the knowledge of how to use gettext or other more advanced tools and XML is […]

Fredrik Holmström on Sep 20th, 2008PHP Templating in 5.3+

So, if you read my last post about pQuery you’d be familiar with me working on a way to enhance the PHP templating “experience”. I wasn’t very happy with how pQuery-0.1 turned out in the end as it’s way to bulky to split it up in several files, so I started glancing at PHP5.3 and […]

Fredrik Holmström on Sep 20th, 2008Javascript-OO & Python-DuckTyping in PHP5.3

With the introduction of closures in PHP5.3 my mind has been working a lot trying to find new (ab-)uses for them, first out is a combination of javascript and python oo - honestly this object model is nicer then the standard PHP one.
This allows for changing objects methods during runtime, proper duck-typing, monkey-patching and a […]

Fredrik Holmström on Sep 18th, 2008PHP 5.3 and closures

<?php
function test() { return function() { echo “foo”; }; }
test()(); // fails
$func = test(); $func(); // works

Why, oh why!

Fredrik Holmström on Sep 17th, 2008pQuery - Messing with the DOM from PHP

You can download the complete source-code + example here
So, this is a small pet-project I managed to get running with a decent API last night, it’s YAPTE (Yet Another PHP Templating Engine), but bare with me for a few minutes. My huge gripe with using PHP as a template language, embedding it within the html, […]