1

Parameters send information to a function, and then the function executes the code. Functions can use anywhere from zero parameters to a whole list of them. In Example 5-1, you’ll use the echo function to display some text. echo displays text that you send to it as a parameter. Most functions require you to place their parameters inside of parentheses, but echo is an exception to this rule. Echoing of all variables is nearly foolproof!

(From Learning PHP & MySQL by Michele E. Davis, Jon A. Phillips, p. 86)

I don't understand what it really says. Maybe it's better to say echoing variables is nearly foolproof!?

2

Programming languages usually have a method for causing a string or variable to be output as text.

  • echo
  • print
  • puts
  • ...

Often these are used in the same manner as any function in the language's standard library, but are often implemented as a language construct rather than an actual function.

The author is pointing out that in PHP, although you can use parenthesis around the input to "echo" you don't need to! I agree that the way the author wrote this is not very clear. He say's that the echoing (printing a variable to the output) is nearly foolproof because if you forget the parens it will still output.

echo $my_var;

is just as correct as

echo($my_var);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.