Archive for the ‘PHP’ Category.

PHP Weather has moved

PHP Weather logo Next up on the list of things that people mistakenly still believe is to be found here on my site is [PHP Weather][]. I created PHP weather some five years ago, and in the beginning it lived its live on my site.

But it has since been moved to SourceForge, and has even gotten it’s own nifty domain name: So please update your links to point to that site instead of mine.

No more `showsource.php`

Some 250 people (this month alone) have tried to access my old script to show the source of [PHP][] scripts. Showing the source of a PHP script in a colorful way is trivial using the highlight_file() function, which is a built-in PHP function.

My little script had just a small amount of extra functionality: it tried to find URLs and file names and substituted them with links. Unfortunately this is such a crude hack that I’ve removed the file.

For much better replacements, please see the PEAR Text_Highlighter class (support for 11 languages) or the Generic Syntax Highlighter (support for 35 languages).

Hmm, all this reminds me that I still haven’t installed a plugin to let me do syntax highlighting in my own posts…

Enhanced Markdown

After the migration to I’ve been busy updating links on my site, and also a bit outsite whenever I found them. While doing so I thought a bit about how the current link structure of the Web works, or rather how it doesn’t always work.

For example: After I started redirecting people using standard HTTP “301 Moved Permanently” headers, smart search engines such as Google automatically updated their links to point to I wish that kind of auto-updating links were implemented more often!

The basic problem is that content sometimes more around in Cyberspace, so links need to be updatable. Of course one can just go through all links by hand and update them — and I’ve also partly done so, with the help of some SQL of course.

But the real solution is some kind of indirection. To make it easier for myself to do exactly that I’ve decided to seed the list of links in [PHP Markdown][] with a bunch of often used links. This means two things

  1. I can easily change all links to, say, [PHP][] if the needed be. I might decide one day that I would like to have a page here at describing PHP, with links to my tutorial and other PHP related projects I’m involved in.

    (Hint: I’ve had exactly such a page back in an old version of, and I’ve now been updating lots of stale links pointing to /php/index.php. So the example is very real…)

  2. I can make lots of links very conveniently, knowing that they are predefined with a correct URL and title. I can, for example, write something about [Emacs][] and make a link by writing ...something about [Emacs][] and making…. Simple isn’t it?

The seeding is very simple: I’ve just changed the initialization of $md_urls and $md_titles from empty arrays to arrays with the content I want. So for example with

$md_urls = array('gnu' => '');
$md_titles = array('gnu' => 'GNU's Not Unix!');

I can afterwards link to the [GNU homepage][GNU] using reference links with gnu as the link label. Just remember that the labels are converted into lower-case before being used — this means that writing [GNU][] works as expected because the label GNU is converted into gnu and then used to lookup the URL and title.

The changes must be made in the beginning of the Markdown function, about 13% into markdown.php.

Reading PhpWiki wiki markup

I’ve been looking on how to convert my legacy news posts from their PhpWiki format into Markdown so that I can re-publish them here in WordPress. Extracting the text of the wiki-pages and turning them into posts in WordPress is not hard — that’s more or less just a matter of selecting them from one table and inserting them into another.

But converting the wiki markup is harder — I guess that the only thing that can really read the PhpWiki wiki markup is PhpWiki itself, which also kind of makes sence… :-) The problem is that the parser in PhpWiki is quite advanced — it’s not just a dumb line-by-line parser — and I don’t know yet if I can easily use it without having to get the whole PhpWiki system going.

In the end I probably end up doing a quick-and-dirty conversion followed by a manual cleanup sweep through the about 100 old posts. You’ll know when the posts are here by the number of archive links to the right — I should really make them into a select box or something like that…

Finding a cheap PHP5 host

I’ve been looking for a hosting provider that would give me PHP5 at a decent price. NETsite have already upgraded to PHP5, but they’re somewhat expensive, demanding 111 DKK (about 15€) a month. There are plenty of other Danish hosting providers that will give me much more space for far less money.

Finding someone who can provide PHP5 is rather difficult. Neither FastTech, Webdomain, freepaq, NeedHost, nor Dkx can provide a PHP5 solution… At Powerhosting I could buy my own server and then get PHP5 on it, but it would be more expensive than staying with NETsite.

At ComSupport Gruppen they are waiting for official Debian of PHP5 — but those packages have been stalled for over six months now… It’s a bit unclear why Debian hasn’t got any PHP5 packages by now, especially since Piotr Roszatycki uploaded them a couple of months ago. But apparently they weren’t acceptable to the ftpmasters. But instead of working on getting the packages acceptable things just stopped :-( I think that’s rather sad… Debian is about to release Sarge, and having PHP5 in it would be a nice plus, especially if it would mean that people would upgrade to it.