PHP

Translate a nested heirarchical array into another heirarchical array

August 17, 2008

Yes, that does sound like a pointless title. Let me explain the situation, we have a self referential model, Pages, which has child pages and a parent page. Because I’m using CakePHP for this project I have added the Tree Behaviour to the model also which is really handy, but you don’t need that behaviour [...]

CakePHP deployment errors

August 12, 2008

If you have set cakephp up so that DocumentRoot of apache is pointing to app/webroot/ you might have encountered a couple of errors like these – not the first time you set it up, but consequent attempts to remove and replace the files.

CakePHP redirect to admin methods

July 30, 2008
Thumbnail image for CakePHP redirect to admin methods

If you have admin routing set: Configure::write(’Routing.admin’, ‘admin’); Redirecting between admin_* and non admin functions inside the controller, or linking to admin_* functions from non admin views can throw an error unless you pass an admin variable in the URL.

Carriage Returns in PHP Plain Text Emails

April 3, 2008

Another quick tip for the archives. Carriage returns on lines in your view finishing with a php statement. Try sending these views as an email and somehow the resulting email does not look entirely correct. The carriage returns have not been passed through. This is a quick, hackish, tip so I really didn’t get to [...]

Nested Ternary Statement PHP

March 30, 2008

Moving complex php if statements into ternary statement syntax is not always recommended, but I think it can look quite neat and easily readable. Ternary statements compress your code and using nested ternary statements sparingly in certain situations makes a mess of nested if statements far easier to scan when converted to a nested ternary. [...]

Validate Unicode/UTF-8 Form Input (Language Specific Characters)

March 9, 2008

Validating language specific characters in user input can be a bit of a pain, especially if you are using regular expressions to filter user submitted data. Not only that, but testing your methods can also be a pain – firstly you will need some shortcuts for entering UTF-8/Unicode chars into form inputs if you are [...]