Introduction
This superglobal variable is available when a PHP script is run from command line (and not when executed from HTTP server's document root). It is an integer that corresponds to number of command line arguments passed to current script. As script's filename has to be entered in command line, minimumn value of $argc is 1. This variable is not available if register_argc_argv directive in php.ini is disabled.
$argc
Following script is expected to be run from command line with 3 arguments including name of script
Example
<?php if ($argc!=3){ echo "invalid number of arguments"; die(); } else{ echo "number of arguments is valid"; } ?>
Output
This script is run with invalid number of arguments
C:\xampp\php>php test1.php 1 2 3 invalid number of arguments
This script is run with valid number of arguments
C:\xampp\php>php test1.php 1 2 number of arguments is valid