Peter Bissmire

Communications & Language Services

Technical and general translations, French/German -> English

17-06-11

Today, the PHP version of the site went live.

This version also introduced the dropdown menu for the blog area.

Why PHP? For two main reasons.
1. The non-scripted (static) portions of the mark-up can be written in plain HTML rather than using print statements.
2. It avoids appending "/cgi-bin/filename.cgi" to the URL.
A similar result could be achieved using scraps of PERL cgi script with SSI includes but with the penalty of fragmenting the page.

PERL

@values=($value1, $value2, $value3);
foreach $value (@values) {...

PHP

$values=array($value1, $value2, $value3);
foreach ($values as $value) {...


PERL

$string =~ s/^(\w{3})\w*/$1/;

PHP

$string = preg_replace('/^(\w{3})\w*/', "$1", $string);

PHP is a sort of greatly extended SSI, enabling scripting to be kept at its place within an HTML document . This gives it some vague relationship with PERL and there are useful similarities between the syntaxes of PHP and PERL.

Unfortunately, PHP failed to make proper use of PERL's prefix characters - $ for scalar, @ for array and % for hash (associative array). All PHP variables begin with $ (not obligatory in SSI). The class of the variable must be declared on creation if it is not a scalar and not contextually self-evident, making the handling of arrays relatively clumsy.

PHP does not understand , so a list of assignments is required where only one would do in PERL.

Patern matching (perl-style regular expressions) in PHP is also rather strange. The examples shown abbreviate a single-word string to its first three characters (e.g. days of the week). Why PHP needs the quotes (can be single or double) enclosing the function parameters is a mystery. Still, "Real programmers can write assembly code in any language": Larry Wall.

A perfectly satisfactory dropdown menu can be achieved with styles alone - so no need for more javascript or exclusion from use for noscript clients. Styles can handle states, e.g. "do something while hover". Client-side scripting is needed to handle events, e.g. "do something when (on) click".