What’s the difference between parameters and arguments?

When writing books aimed at beginners, there’s a difficult line to tread between giving too much and too little information. Too much information overloads the mind, running the risk of losing the reader’s enthusiasm for the subject. Too little information leaves questions unanswered.

Chapter 3 of my PHP Solutions, 2nd Edition makes for pretty heavy reading. So much so that I recommend stopping halfway through on the first pass. That’s why I skirted around the difference between parameters and arguments on page 43. But I’ve piqued the interest of Tom Flis, one of the participants in Boston PHP‘s self-study group PHP Percolate. He’s asked what’s the technical difference between the two words, so here goes. It’s actually quite simple.

When you define a function, the variables that represent the values that will be passed to it for processing are called parameters. For example, the following function definition has one parameter called $number:

function doubleIt($number) {
return $number *= 2;

However, when you use a function, the value you pass to it is called an argument. So, in the following case, $price is passed as the argument to doubleIt():

$price = 50;
$inflated_price = doubleIt($price);  // 100

It’s a pretty subtle difference. A parameter contains no value; it’s simply a placeholder for the value that will be passed to the function. An argument contains a value (even if it’s null or an empty string) that the function processes to produce a result. Because the meanings are so similar, many developers use the words interchangeably or always refer to arguments.

So, now you know.

This entry was posted in Books, PHP. Bookmark the permalink.

4 Responses to What’s the difference between parameters and arguments?

  1. Juan Criado says:

    Dear David

    I bought your book
    PHP Solutions
    Dynamic Web Design Made Easy
    2nd Edition
    Amazon.com: Order (D01-8889175-0745133) (Kindle for PC edition)

    The issue is that when I try to download the source code of your book from

    the downloaded zip file is corrupted.

    Please, ¿where canI get a correct zip file?

    Thanks a lot in advance

    Juan Criado

  2. David Powers says:

    I have just downloaded the files from the Apress site, and there’s no problem with them. For some reason, they have been packaged as a zip file inside another zip file. When you unzip 9781430232490.zip, you should get phpsols.zip, which you can then unzip to gain access to all the files.

    If you’re having problems, it’s often caused by the browser you’re using to download the files. Have you tried using a different browser?

  3. Dear David,

    I also bought your book PHP Solutions Dynamic Web Design Made Easy 2nd Edition through a parent of mine, at page 31 “Embedding PHP in a web page” I tried the PHP code but the result at my web browser (IE ver. 8) does not show the dates, it only show the following:
    “Embedded Code
    PHP code can be embedded directly in the body of a web page.

    © PHP Solutions” not what was expected as written in your book (the years are missing).

    Can you please inform me what whent wrong ?
    An e-mail notification would be really appreciated.

  4. David Powers says:

    It sounds as though Apache isn’t running.