PHP Command Line Use
PHP on the Command Lines
The figure below shows the command options available when running PHP in
command line mode.
The last setting, max_executon_time, is helpful
when using the -a interactive mode option. Otherwise when running specific
files you may not want to set max_execution_time because if a program
has an infinite loop error it will eat up hours of execution time unless
manually cancelled. The screen shot below shows a debug session done in command
line mode - no browser, no localhost web server, just direct command line
calls on PHP 5. This is very convenient for doing parsing tests or testing
code - particularly file I/O or database report results.
The results are very informative. First, splicing an associative array onto the stack is a destructive operation - the key is lost after the splicing as can be seen when the array is dumped with the print_r($xa) command. The next step shows that when the item is popped from the array/stack only the value is shown, not the key. Finally, popping an item from the stack does what it should - it deletes the item from the array/stack.
It is this type of quick check and testing of PHP code without need for
browser or web server that makes the new PHP5 CLI-Command Line Interpreter
so helpful. We use it also to do all sorts of DOS and Windows file and database
manipulations since it is powerful and convenient.In sum, ytry the new command
line mode of PHP 5 - it makes PHP much more approachable and exposes its
adhoc utility capabilities. The result for this developer - no more complicated
and hard to maintain .sh or .bat scripts.
Top of Page Home Tips & Tutorials
© Imagination 2001-2004