Despite the fact that I don’t know how many people read this the day it’s published – or that it matters, really – I’ve almost always shared a note of thanks on Thanksgiving Day on this site for just about as long as I’ve been writing on this blog.
TL;DR: $argv is an array of arguments passed to the script with the first index being the name of the script itself. And $argc is the number of arguments passed to the the script (which will always at least be 1).
Arguably, pun intended, one of the key pieces of command-line application is making sure that they are interactive through command-line arguments. In PHP, there are two variables to understand:
$argc is the number of arguments passed to script. Note the script’s filename is always passed as an argument to the script, therefore the minimum value of $argc is 1.
$argv is an array of arguments passed to script. Note the first argument $argv is always the name that was used to run the script.
Just Getting Started with WordPress? I write a lot about WordPress development but if you're just getting started, I recommend checking out WPBeginner. They have free training videos, glossary, and more.