| ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot |
Managing command line argumentsManaging command line arguments –
how to add arguments to the parser and use them
Some backgroundArguments are for those pieces of information that your program absolutely, positively requires to run. A good user interface should have as few absolute requirements as possible. If your program requires 17 distinct pieces of information in order to run successfully, it doesn't much matter how you get that information from the user, most people will give up and walk away before they successfully run the program. This applies whether the user interface is a command-line, a configuration file, or a GUI: if you make that many demands on your users, most of them will simply give up. In short, try to minimize the amount of information that users are absolutely required to supply and use sensible defaults whenever possible. Of course, you also want to make your programs reasonably flexible. That's what options are for. Adding arguments with Console_CommandLineTo add arguments to your parser, just create the parser as explained in the previous section and use the Console_CommandLine::addArgument() method. The Console_CommandLine::addArgument() method takes two arguments:
Adding commandline arguments
<?php
If the user type:
$ <yourprogram> file1 file2 file3
The output of the above script will be:
Array ( [input_files] => Array ( [0] => file1 [1] => file2 ) [output_file] => file3 )
|
各種マニュアル:
PHPマニュアル |
PEARマニュアル |
Smarty(英語)マニュアル |
PHP-GTKマニュアル |
「Managing command line arguments」をGoogle検索
|