getopt

(PHP 4 >= 4.3.0, PHP 5)

getopt -- コマンドラインの引数リストからオプションを取得する

説明

string getopt ( string options)

オプション/引数のペアを連想配列で返します。 オプションのフォーマットはoptionsで指定します。 エラーの場合FALSEを返します。

<?php
// parse the command line ($GLOBALS['argv'])
$options = getopt("f:hp:");
?>

options引数は次のような内容を書きます: 引数を特定するための個別の文字と、それに続くコロン。例えば、 オプション文字列x-xという オプションを認識します。x:-x argumentというオプションとその引数を認識します。 オプションと引数の間に空白があるかどうかは考慮されません。

This function will return an array of option / argument pairs. If an option does not have an argument, the value will be set to FALSE. この関数はオプション/引数のペアを連想配列で返します。 オプションが引数を持たない場合、値にはFALSEがセットされます。

注意: この関数はWindows環境にはまだ実装されていません。