Entries from May 1, 2010 - May 31, 2010

Wednesday
May122010

The CodeIgniter End-of-File Comment Convention

From the CodeIgniter User Guide:

The PHP closing tag on a PHP document ?> is optional to the PHP parser. However, if used, any whitespace following the closing tag, whether introduced by the developer, user, or an FTP application, can cause unwanted output, PHP errors, or if the latter are suppressed, blank pages. For this reason, all PHP files should OMIT the closing PHP tag, and instead use a comment block to mark the end of file and it's location relative to the application root. This allows you to still identify a file as being complete and not truncated.

INCORRECT:

<?php

echo "Here's my code!";

?>

CORRECT:

<?php

echo "Here's my code!";

/* End of file myfile.php */
/* Location: ./system/modules/mymodule/myfile.php */

I agree that it is a good idea to omit the PHP closing tag, and also to mark the end of file with a comment. But I think it is a bad idea to embed the name and location of the file in that comment. This introduces an unnecessary dependency between the internal contents of a file and its name and location. It should be possible to rename or move a file without having to change its contents. Embedding the file name and location make this impossible. This is particularly ironic as one of the first operations that many people perform after installing CodeIgniter is to move the application directory up one level (see the CodeIgniter video tutorials by Jeffrey Way, for instance).

Wednesday
May122010

Longhorn Moths

A female longhorn moth, probably Adela reaumurella (Lepidoptera: Adelidae).  Some sources put these moths in the Incurvariidae, but nowadays they seem to be assigned to the narrower family Adelidae.  As with Nemophora degeerella, the males have much longer antennae than the females:

More details on this species can be found at Hants Moths and at Wikipedia, the latter including pictures of A. reaumurella swarming!

Photos taken in Whiteknights Park, Reading University grounds, Reading, UK, on 2010-05-06 (the female) and 2010-05-10 (the male).

Tuesday
May112010

Malachite Beetle

A malachite beetle, Malachius bipustulatus (Coleoptera: Melyridae).  Its family is sometimes given as Malachiidae but this now seems to have been merged into the family Melyridae.

Photo taken in Whiteknights Park, Reading, UK, on 2010-05-06.

Monday
May102010

Dagger Fly

A male dagger fly, probably a species of Rhamphomyia, possibly Rhamphomyia sulcata (Diptera: Empididae).

Photo taken in Whiteknights Park, Reading University grounds, Reading, UK on 2010-05-05.

Sunday
May092010

Ant-Like Bug

Originally I thought this was a nymph of the ant damsel bug, Himacerus mirmicoides.  However, on looking again at British Bugs, I now think it is a nymph of the capsid bug Miris striatus (Hemiptera: Miridae).  Only the early instar nymphs resemble ants; the adults look like fairly normal bugs.

Photos taken in Whiteknights Park, Reading University grounds, Reading, UK, on 2010-05-06.