You are browsing the archive for PHP.

Don’t use IsValid in your Doctrine Models – a warning

September 9, 2010 in Doctrine, PHP, Web Development

Recently for a project i’ve been making heavy use of Doctrine. In one of the models I had a method to check to see if the object was valid under a certain set of conditions. I named this function isValid .. and it had 2 params. Little did I know that this was actually overriding [...]

PHP – Chmod-ed to Windows hell and back

March 10, 2009 in PHP

Today has not been a good day. With various things going wrong, I was please that I had got the file upload code done for a site i’m working on. All I needed to do was make sure that the file had the right permissions and then edit it via GD (via an image editor [...]

php: processing raw Post / Get Values

January 21, 2009 in PHP

I just added a jquery plugin to call head requests, but because you are not doing a get or post request php won’t convert the values that are sent back to their form. To get around this we have to use the php://input stream ( is that the right word?) which is handy for a [...]

php: smarty assign content plugin

January 12, 2009 in Smarty

I needed to assign a block of content to a variable instead of just a value.. so i set about creating this plugin function smarty_block_assign_content($params, $content, &$smarty) { $smarty = clone($smarty); //Copy the original class, so there's no garbage variables after we finish if(!isset($content)) return; if (!isset($params['var'])) { $smarty->trigger_error("assign_content: missing 'var' parameter", E_USER_WARNING); return; } [...]

php: Menu Classes

January 12, 2009 in PHP

Recently I’ve been working on my own framework (we’ve all done it i’m sure) and part of this was a menu handling system. The basis really is simple, we have a menu item which really is just link and text. That menu item could have children, could be active and/or be selected. In this case [...]

php: Insert element at specific Index of Array.

January 11, 2009 in PHP

In a recent project I’ve been undertaking I’ve made a menu class set and sometimes i just wanted to say to add this to an array, but in a certain position. PHP does this easily via $array[position] = "newdata"; But unfortunately this is not so good if you only wanted to insert the newdata into [...]