Finding command line arguments in php script

A good way to look for particular arguments passed on the command line to a PHP script.
Author: Nate Baxley
Published Date:9/10/2008
The code below will grab the -f argument and stick it in the $filename variable.

[code]
    $filename = '';
    for ( $c=0; $c<$argc; $c++) {
        if ( $argv[$c] == '-f' ) {
            $filename = $argv[$c + 1];
            break;
        }
    }
[/code]
RSS Feed Log In to access RSS feeds.


Remember me on this computer

This Item Tagged as


Hover over an item above for
more information