Interesting Things

Richard Bradshaw's idea of what is interesting

Tag: PHP

Dynamically drawing gradients with PHP

Just a little script to create a PNG image of a simple linear gradient using PHP. You could adapt this to make it better in many ways! Insipired (by which I mean 99% ripped of!) by http://www.cutcodedown.com/ No demo to avoid load on the server, but it just makes a simple gradient. I use it [...]

How to know that your PHP is borked before your clients kill you

Maybe it’s just me, but every now and then I make a quick change to a PHP script, don’t bother checking it, then a few hours/days/months later either realise that I missed a vital semicolon, or mismatched a bracket. This started to get on my nerves, as now this has happened a couple of times [...]

Using Texter to speed up web design/development

Lifehacker’s Texter let’s you define short macros that allow you type a little, and get a lot back. I’ve not used this before, but am constantly finding myself typing the same bits over and over and over, so this is a very neat and helpful little tool. Basically, you just define a command, then specify [...]

Enable better caching on your website using PHP

Just a quick snippet to help you tell useragents accessing your site that the content hasn’t changed. ?View Code PHPfunction caching_headers ($file, $timestamp) { $gmt_mtime = gmdate(’r', $timestamp); header(’ETag: "’.md5($timestamp.$file).’"’);   if(isset($_SERVER[’HTTP_IF_MODIFIED_SINCE’]) || isset($_SERVER[’HTTP_IF_NONE_MATCH’])) { if ($_SERVER[’HTTP_IF_MODIFIED_SINCE’] == $gmt_mtime || str_replace(’"’, ”, stripslashes($_SERVER[’HTTP_IF_NONE_MATCH’])) == md5($timestamp.$file)) { header(’HTTP/1.1 304 Not Modified’); exit(); } }   header(’Last-Modified: [...]

Friendfeedifying your feeds

Although these tips are designed for feeds used with Friendfeed, the first two aren’t just for that – it’s just that Friendfeed exposes the extra functions in it’s interface. The third tip regarding SUP currently is only really relevant for Friendfeed.

5 mistakes new web developers often make

Image via Wikipedia Having talked to some university students who had taken computer science/IT degrees, I was amazed by how little they seemed to know about making anything that’s secure or even remotely logical. The group I met with primarily had been taught PHP. Having looked at some sites they were designing I realised 5 [...]