PHP command line - passing script agruments

PHP, Perl, XHTML, DHTML, Java, DOM, Bash, etc.

PHP command line - passing script agruments

Postby Taehoon on Tue Sep 11, 2007 5:35 pm

Here is an example of passing a script’s agruments to the PHP program from the command line:

file: test.php
Code: Select all
#!/usr/local/bin/php
<?
var_dump($argv);
?>


Output:
Code: Select all
shell> ./test.php -hello -hi
array(3) {
[0]=>
string(10) "./test.php"
[1]=>
string(6) "-hello"
[2]=>
string(3) "-hi"
}


References:
Using PHP from the command line.
Taehoon
Site Admin
 
Posts: 70
Joined: Sun Sep 09, 2007 3:43 pm



Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron