run php file from command line

by RameshKumar 2008-02-21 16:51:26

You can execute a php file from command line.
While executing an file from command line you can also give input for a variable.

For Example create a file and save it as hiox.php, now add the following code::
<?php
$i = $argv[1];
echo "$i";
?>

Execute php file from command line:
php hiox.php 12

the above will execute the file hiox.php and 12 will be the input.
$argv[1] will get the input 12 and the output will be printed as 12.







Tagged in:

1538
like
0
dislike
0
mail
flag

You must LOGIN to add comments