<?php
$fo = fopen('php://output', 'w');
$fs = fopen('php://stdout', 'w');
fputs($fo, "You can see this with the CLI and Apache.\n");
fputs($fs, "This only shows up on the CLI...\n");
fclose($fo);
fclose($fs);
?>
When you're writing one line php scripts remember that 'php://stdin' is your friend. Here's a simple program I use to format PHP code for inclusion on my blog:
UNIX:
cat test.php | php -r "print htmlentities(file_get_contents('php://stdin'));"
DOS/Windows:
type test.php | php -r "print htmlentities(file_get_contents('php://stdin'));"
want a directory full of php files to be showns as source instead of being interpreted? don't want to rename every one from *.php to *.phps? then apache's forcetype directive is for you. drop this little baby into your .htaccess file and you'll be good to go.
<FilesMatch "\.(php)$">
ForceType application/x-httpd-php-source
</FilesMatch>