Mix PHP and namespaces, get weirdness

Tags:

In an interesting decision, the PHP devs have decided to use a backslash, \, as the namespace separator. This is a bit… curious.. choice of a character. They apparently had a long discussion about their choices, but really, couldn’t they just have used ::, as the manual showed for a while? It’s starting to feel like the fact that PHP …

Handling different page types in a CMS

Tags:

I’ve often been asked whether my CMS is public, whether the code is available, etc. – the answer at the moment is no, but information about it is public… so for your reading pleasure, here’s some information on how I’ve handled the issue of different page types. All pages share some details, such as name, id, location in the page …

Cross-device Opera Widgets challenge

Tags:

Opera has launched another widget competition: The x-widget challenge. The goal is to make the best cross-device widget – this means the widget has to work on mobile phones running Opera Mobile 9.5, which supports widgets, and in Opera on your computer.

Complex custom elements in Zend_Form

Tags:

I’ve sometimes needed custom elements in forms – say two fields for inputting two numbers. For something simple like that, adding two separate elements usually suffice, but when one of my clients wanted a field with multiple checkboxes, but only specific pairs could be selected, it started getting too complex. Until then, I had kind of avoided making those custom …

ModelForm developments

Tags:

I’ve been reworking the ModelForm class for ZF a bit. Earlier this year, I discussed porting it to use Zend_Db_Table with Matthew Weier O’Phinney, for using it with Zend Framework. I initially had done some checking on Zend_Db_Table, and some small code changes to modify the class to use it instead of Doctrine, but I ran into some issues. Now, …

“Multi-touch” with your webcam

Tags:

There’s an interesting project from Microsoft’s OfficeLabs: Touchless, a project which allows you to utilize a webcam to do multitouch style input on your PC. The basic idea is something I’ve thought about as well – have a webcam track a colored object, and use that as a “cursor”. The touchless demo is very promising, although at this time it …

How to CSRF protect all your forms

Tags:

CSRF, or Cross-Site Request Forgery, is a vulnerability very common in websites. In short, it means that if you have your site at foo.com, and an attacker at badguy.com can display a form similar to one of your site’s, and make users on his site submit the forms on your site, possibly without their knowledge. This can be dangerous, especially …

Zend Framework – good for beginners or not?

Tags:

I’ve heard some inexperienced PHP programmers say that Zend Framework is confusing to them. Until today, I have agreed: Zend Framework has a lot of classes and some of them are quite complex (such as Zend_Form). But does that actually make it more difficult for inexperienced programmers than other frameworks?

PHP tip: How to make a file downloadable through your script

Tags:

This seems to be a relatively common question on #zftalk nowadays, so here’s a quick wrapup! The traditional plain-PHP way $file = file_get_contents(’some.zip’); header(’Content-Type: application/zip’); header(’Content-Disposition: attachment; filename="some.zip"’); header(’Content-Length: ‘ . strlen($file)); echo $file;$file = file_get_contents(‘some.zip’); header(‘Content-Type: application/zip’); header(‘Content-Disposition: attachment; filename="some.zip"’); header(‘Content-Length: ‘ . strlen($file)); echo $file; The Zend Framework controller way //this is inside an action in one of …

Static/Dynamic typing sweet spot

Tags:

Commenter TurboC linked an interesting talk about the future of programming languages. This got me thinking about something I had thought about before: It seems that PHP has moved a bit towards static typing, and languages like C# seem to be implementing some dynamic features. Are we going towards a “mixed” language with static and dynamic typing? What’s the “sweet …