I wrote a println function that determines whether a \n or a <br /> should be appended to the line depending on whether it's being executed in a shell or a browser window. People have probably thought of this before but I thought I'd post it anyway - it may help a couple of people.
<?php
function println ($string_message) {
$_SERVER['SERVER_PROTOCOL'] ? print "$string_message<br />" : print "$string_message\n";
}
?>
Examples:
Running in a browser:
<?php println ("Hello, world!"); ?>
Output: Hello, world!<br />
Running in a shell:
<?php println ("Hello, world!"); ?>
Output: Hello, world!\n