Category: PHP

Two new features I really like in PHP 5.3

Namespaces Finally PHP has support for namespaces, not one day too late! Before the days of object oriented PHP name clashes for functions was usually prevented by adding a prefix to your function names. When object oriented PHP was introduced function name clashes was less likely, but class names still had to be unique, ie…

Friendly URLs and the Zend Router

Creating custom friendly URLs using the Zend framework is really simple. The default routing setup for Zend is : ‘:module/:controller/:action/*’, (* will match any var/value) which is fine for most setups. However on some pages having the var/value might not look very good, for example this url is not very readable: /popular/index/type/images/page/1/sortOrder/alltime (controller/action/var/value/var/value/var/value) We would…

Creating a custom View Helper in the Zend Framework

Zend Framework ships with several View Helpers, such as the url View Helper. Anywhere in a view script one can call $this->url() to generate a url to a certain page. For example: $this->url(array(   ‘module’ => ‘moduleName’,   ‘action’ => ‘actionName’,   ‘additionalParam’ =>‘value’)) I wanted to create my own helper, for generating paths to…