Command Line arguments - PHP
- by Chaitanya
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?