# Passing command-line arguments into PHP

Say you have a <span class="caps">PHP</span> script and you want to pass command-line arguments into the script, e.g. calling the script like this:

```
php script.php datafile.txt 10 100
```

<span class="caps">PHP</span> stores all command-line arguments in an array:  
$argv <sup class="footnote">[0](#fn0)</sup> =&gt; “script.php”  
$argv <sup class="footnote">[1](#fn1)</sup> =&gt; “datafile.txt”  
$argv <sup class="footnote">[2](#fn2)</sup> =&gt; 10  
$argv <sup class="footnote">[3](#fn3)</sup> =&gt; 100

Then you can process the arguments:

```
<br></br>if (!isset($argv<sup class="footnote"><a href="#fn1">1</a></sup>) {<br></br>print “Usage: php script.php  [ ]\n”;<br></br>exit(1);<br></br>}<p>$filename = $argv<sup class="footnote"><a href="#fn1">1</a></sup>;</p><p>…<br></br></p>
```

See the article [Using <span class="caps">PHP</span> from the command line](http://aspn.activestate.com/ASPN/docs/PHP/commandline.html) for details.