PHP Tutorials
Php What isPHP INI Tutorials
Php ini What isThe print() statement outputs data passed to it to the browser.Its prototype looks like this:
All of the following are plausible print() statements:
All these statements produce identical output:
Note : Although the official syntax calls for the use of parentheses to enclose the argument, they're not required. Many programmers tend to forgo them simply because the target argument is equally apparent without them.
Alternatively, you could use the echo() statement for the same purposes as print().While there are technical differences between echo() and print(), they'll be irrelevant to most readers and therefore aren't discussed here. echo()'s prototype looks like this:
As you can see from the prototype, echo() is capable of outputting multiple strings. The utility of this particular trait is questionable; using it seems to be a matter of preference more than anything else. Nonetheless, it's available should you feel the need. Here's an example:
This code produces the following:
If your intent is to output a blend of static text and dynamic information passed through variables, consider using printf() instead, which is introduced next. Otherwise, if you'd like to simply output static text, echo() or print() works great.
|
Tweet |
|
|