· Travis Rodgers · Programming · 2 min read
The Difference Between a Parameter and an Argument
Is there a difference between a parameter and an argument? Are they synonymous with one another?
I've been guilty of it myself when talking about functions……using the words parameter and argument interchangeably.
I mean, they both come after the function name in the parentheses right?
Right!
Then what's the difference between a parameter and an argument?
Our Example
Let me explain in this very simple function:
```php function squared(number) { return number * number; } ```Parameter Explained
The parameter of this function is number.
This is the variable name used to reference the arguments passed to the function.
It can be named anything, but you should choose something relevant.
Argument Explained
The argument of this function will be what you actually pass to it.
When we call this function we will pass a real number as an argument like this:
```php squared(4); ```The argument is 4 and the function will return 16.
If we passed 5 as the argument, the function will return 16.
Conclusion
As you see, this is a subtle but important difference in terms.
Our function has number as the parameter used to reference the argument we will pass to the function (4 or 5 as our examples above).
Hope this helps next time we use the two terms.
Have you mixed these two up before? I think we all have!!