PHP

PHP is a dynamically typed language. It supports a number of different programming paradigms including imperative and object oriented features. PHP code is generally interpreted but several systems for producing compiled code are available.

PHP is designed for developing web applications, and generally has little use in other scenarios. It is easy to integrate with a wide range of other technologies.

Example Code

Here is an example of the 100 doors problem:

<?php

function doors ($n) {
    // Create a new array with n entries starting from 0, all set to CLOSED)
    $doors = array_fill(0, $n, false);

    // Now, start opening and closing
    for ($step = 0; $step < $n; $step++) {
        for ($idx = $step; $idx < $n; $idx += $step+1) {
            // Toggle state of door
            $doors[$idx] = !$doors[$idx];
        }
    }

    // Find out which doors are open
    foreach($doors as $i => $door) {
        if ($door)
            echo "Door #" .($i+1) . " is open.\n";
        else
            echo "Door #" .($i+1) . " is closed.\n";
    }
    
}

doors(100);

?>

Why would I learn this language?

PHP as an environment is very easy to deploy. It is generally combined with Linux, Apache and MySQL (a LAMP setup). This makes it ideal for simple web applications and projects.

One great feature of PHP as a community is the documentation. There are fantastic resources available on the main PHP website, and there are many external resources discussing PHP programming and related topics.

PHP provides integration with many other libraries, such as databases, image manipulation and network communication. However, each external library tends to have its own syntax and semantic behavior. This can make larger programs unmanageable without careful planning.

Starting Points

PHP Programming Wikibook
A comprehensive guide to learning to program using PHP.

Further Reading