Command Line arguments - PHP
Posted
by Chaitanya
on Stack Overflow
See other posts from Stack Overflow
or by Chaitanya
Published on 2010-06-13T03:46:48Z
Indexed on
2010/06/13
3:52 UTC
Read the original article
Hit count: 304
Am trying the following php script which finds out the maximum between 2 numbers, it accepts the arguments through command line. I check whether the input is provided right, based on the number of command line arguments.
<?php
function larger($arg1,$arg2) {
return max($arg1,$arg2);
}
if($argc > 3 || $argc < 3) print 'Invalid Arguments'; exit(1);
if($argc==3) {
print larger($argv[1],$argv[2]);
}
?>
Am executing the program in a windows system, and the file resides in xampp/php directory. While executing I don't get any output neither any error report. How do i check whether am right or wrong?
© Stack Overflow or respective owner