downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

定義済みの例外> <$argc
Last updated: Fri, 13 Nov 2009

view this page in

$argv

$argvスクリプトに渡された引数の配列

説明

コマンドラインから実行したときに、 現在のスクリプトに渡されたすべての引数の配列が含まれます。

注意: 最初の引数は、常に現在のスクリプトのファイル名となります。 したがって、$argv[0] はスクリプトの名前となります。

注意: この変数は、register_argc_argv が有効になっている場合にのみ使用可能です。

例1 $argv の例

<?php
var_dump
($argv);
?>

このサンプルを php script.php arg1 arg2 arg3 と実行します。

上の例の出力は、 たとえば以下のようになります。

array(4) {
  [0]=>
  string(10) "script.php"
  [1]=>
  string(4) "arg1"
  [2]=>
  string(4) "arg2"
  [3]=>
  string(4) "arg3"
}



add a note add a note User Contributed Notes
$argv
Steve Schmitt
15-Sep-2009 01:57
If you come from a shell scripting background, you might expect to find this topic under the heading "positional parameters".
karsten at typo3 dot org
18-Feb-2009 09:48
Note: when using CLI $argv (as well as $argc) is always available, regardless of register_argc_argv, as explained at http://docs.php.net/manual/en/features.commandline.php

定義済みの例外> <$argc
Last updated: Fri, 13 Nov 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites