Recently published

Practice notes

Home arrow Blog

Checking for non-ASCII codes

I wanted a simple PHP routine for detecting non-ASCII codes in strings. They are the ones that need some kind of special treatment to appear on web sites. Maybe they can be processed as UTF-8 or maybe they are best turned into HTML elements. On the web, I found a routine for removing non-ASCII characters by a guy called Vivek:

function removeNonAscii($string) {
   return preg_replace('/[^x00-x7f]/','',$string);
} 

Well, that gives the logic required, so we can detect non-ASCII with a rather similar function:

function containsNonAscii($string) {
    return $string == preg_replace('/[^x00-x7f]/','',$string) ? false : true;
} 

#128006 • 03/26/2009 9:50pm by Martin Brampton • Vote: Up votes (835) Down votes (533)

Peer classes in Symfony and Propel

There are a number (perhaps too many) of good PHP frameworks. Symfony is one of them. I like to study their features to see what I can adopt in my own work. Partly because the best ideas are worth copying and partly because it is a pity to create conflicting standards where there is already a good one available.

#128005 • 08/25/2008 12:33pm by Martin Brampton • Vote: Up votes (701) Down votes (507)

Integrating web resources

Semantic markup is a very healthy development. But it's giving me some headaches figuring out how best to handle its ramifications for something like a Content Management System (CMS) or any other system that integrates web material from multiple sources.

#128004 • 08/23/2008 6:05pm by Martin Brampton • Vote: Up votes (684) Down votes (523)

Helpers are unhelpful

It isn't new to have doubts about helpers. One provocative blog by Nick Malik grabbed attention with the title "Are Helper Classes Evil?". That talked about helper classes, defined as classes consisting entirely of static methods. I wanted to broaden the scope and also give my own reasons for trying to avoid helpers.

#128003 • 08/05/2008 2:36pm by Martin Brampton • Vote: Up votes (626) Down votes (497)

Building a PHP CMS

After nearly a year's work, my book on the building of a Content Management System using PHP was finally published in June 2008. Although when I started working on new code for a CMS, most hosting used PHP 4, it seemed clear that such a substantial development should be done in the more advanced PHP 5. One factor was to take advantage of the greatly improved object model, which enabled the CMS design to be much more OO. So the book came to be called "PHP 5 CMS Framework Development" since it talks mainly about my ideas for how best to create the real heart of a CMS. Although it is illustrated with a particular CMS, my Aliro product, the ideas should be applicable to any CMS development. As I review other projects, it is interesting to see many parallels with my code, and also some interesting differences.

#128002 • 07/30/2008 5:29pm by Martin Brampton • Vote: Up votes (630) Down votes (427)

Review of 'Learning Mambo' by Douglas Paterson

Mambo is a powerful and popular piece of software, but it does have problems that it shares with many other open source products. Part of the attraction of Mambo is its flexibility, but a critical factor is the richness of the features that are offered. But this owes a lot to some of the skilled developers who have worked on the system and developers have weaknesses. One of them is a distaste for documentation, so Mambo has extremely patchy documentation. In fact I rather doubt if there is anyone who actually knows precisely how Mambo works in all its ramifications. Including me - would a book help?

#128001 • 03/01/2007 8:16pm by Martin Brampton • Vote: Up votes (653) Down votes (624)

Results 1 to 6 of 6