Displaying messages

The basic instruction to display a message (or variable) is echo.

There is no especific syntax for PHP on many instructions and functions. What I mean is, the basic PHP echo instruction can be used in many ways. Here is an example:

echo "Hello PHP!
";
echo 'Hello PHP!
';
echo ("Hello PHP!
");
echo ('Hello PHP!
');
?>

Result:

Hello PHP!
Hello PHP!
Hello PHP!
Hello PHP!

Comments and Remarks

Sometimes comments on the PHP code is needed to understand certain parts of the code. To add comments and remarks in the code, //, # and /*, */ are available.

Example:

// This is a single-line comment.
# This is another single-line comment.
/* Here is a multiple-line comment for
extensive explanations or some
additional data */
?>

This code is not going to display anything or do anything as the PHP parser just ignores the content indicated by the comment's symbols.

The next articles will provide some useful PHP codes and example on this section. I hope you find it interesting.

Posted in |