July 10, 2017

Core PHP: Echo Syntax (1.2)

Echo

PHP has a built-in "echo" function, which is used to output text.
In actuality, it's not a function; it's a language construct. As such, it does not require parentheses.

Let's output a text.
<?php
echo "I love PHP!";
?>

The text should be in single or double quotation marks.

PHP Statements

Each PHP statement must end with a semicolon.
<?php
echo "A";
echo "B";
echo "C";
?>

Forgetting to add a semicolon at the end of a statement results in an error.

HTML markup can be added to the text in the echo statement.
<?php
echo "<strong>This is a bold text.</strong>";
?>

Result: 
Example: My First PHP Page



No comments:

Post a Comment