simpleGallery 0.2 – Minor updates

I’ve updated the gallery script I created in July. I’ve re-factored the code into a static class for easier modification and have created a config.ini settings file, to save modifying the script itself.

New features:

* Image titles
* Separate configuration
* Standard mode with safe URLs as well as mod_rewrite enabled ‘nice’ URLs
* Added ‘..’ parent folder to galleries

The demo page has been updated and the script is available to download here.

XML Entities in PHP

Because htmlentities() doesn’t even come close.

This small file contains 4 functions (2 of which are taken from the PHP manual, credit given!) which will allow you to encode and decode entities from ASCII/unicode strings in either decimal or hexadecimal format for use in valid XML documents.

The xml_entity_decode() function accepts an optional second parameter to allow non-standard XML entities (that may have been specified in your schema) in the format:

Example usage:

You can get the script here, or there’s a demo here too.

PHP CSV Reader

I’ve never really built a definitive CSV reader and end up building a quick implementation of one any time I need one.

But after working on the chunk script I decided that next time I build a CSV class I’d do it properly.

This is the result:

There’s an information page here, and the script is here.

CakePHP: Components, redirect fail (On my part…)

I’ve been working on a CakePHP project lately and created a small component which was only needed in one of my controllers:

Continue reading “CakePHP: Components, redirect fail (On my part…)”

PHP: Object Oriented Image Manipulation

I’ve been working on a CMS lately and having to create thumbnails for uploaded images is always a pain, lots of maths working out the correct sizes and such, so I’ve created a fairly small script to manipulate images in an object-oriented style.

For example:

I’ve only implemented a few of the GD library methods, but I think these are the most useful methods. I might have to work on something that rounds the corners too, but I don’t have any need for it just yet.

There’s a demo page as ever, and you can get the script here (It’s a bit big, because the sample image is included, here’s one without it).

String Variable Concatenation

I stumbled across something odd today in PHP:

Now, personally, I’d have expected a syntax error from the above code, but the result was even more confusing at first…

Not sure if this was the expected output or not I tested similar code in other languages:

Ruby:

Python:

Javascript:

Perl:

That explains it!

So the reason the string is ‘aaaa’ seems to be that the code is evaluated from right to left:

I don’t think it’s a bug, well, at least I assume not, but is there a name for this?

Update: I asked some clever people for help understanding it.