Got a love note from someone who didn’t appreciate my most web site critique – they said “seems like you are mostly just critisizing, rather than teaching or training, as your banner suggests” … the carnal me wants to reply with a Bronx cheer … but the Christ in me says just move on and return evil with good by posting something really geeky. Especially for those of you with Linux/Apache like web server configurations.
<?php echo “hello world!”; ?>
The nice thing about this is that you can always redirect your STDOUT into file using a syntax to the effect of:
$ php helloworld.php > hello.html
Of course, like any command line tool, there are plenty of arguments and options for PHP which include:
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-w Display source with stripped comments and whitespace.
-f <file> Parse <file>. Implies `-q’
-v Version number
-C Do not chdir to the script’s directory
-c <path> Look for php.ini file in this directory
-a Run interactively
-d foo[=bar] Define INI entry foo with value ‘bar’
-e Generate extended information for debugger/profiler
-z <file> Load Zend extension <file>.
-l Syntax check only (lint)
-m Show compiled in modules
-i PHP information
-h This helpv
Okay Kiddies, now it’s time for the bonus round. Those of you who are asking “yo dean, what about STDERR and STDIN …” … for that and more gory details on how to PHP from the command line, here are some links you might find useful:
Now you don’t have any excuses not to test your code !-)