> echo foo(dog);        // outputs "This is a dog"

This is an example of using a "bareword" - PHP doesn't recognize _dog_ as
any sort of reserved word or constant, so it sends it like a quoted string.
I don't recommend using this because it's ambiguous whether you mean "dog"
or if _dog_ is a constant or whatever else is possible.

> echo foo('dog');        // outputs "This is a dog"

Single-quoted string: this is good for strings that don't need to be
"interpretted" by the parser; it's the ideal way to pass the string 'dog'
to foo() in this case.

> echo foo("dog");        // outputs "This is a dog"

Double-quoted string: this WILL be interpretted by the parser; for example,
if you had to pass the whole string "This is a dog" to the function, but
"dog" could actually be any word contained in $thing, then you'd do
something like this:

echo foo("This is a $thing");

Et cetera...

>
> Does it matter which way I pass my arguments to foo?  All arguments were
> passed as a string variable.

There are some very slight performance changes between these, but mostly
it's a matter of style.

--Toby


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to