echo is using for output one or more strings in PHP.
echo is basically a language construct and not a function. So we can use without parentheses with it.
We can run shell commands also using shell_exec in PHP echo syntax.But its only used in advanced PHP programming and we will discuss more about this in our later posts.
We can use the HTML formatting tags with PHP echo statement
See the following sample program with echo in PHP programs
<?php echo "Good Morning"; ?>
Its out put will be :
Good morning
<?php echo "<b>Good Morning</b>"; ?>
Its out put will be :
Good morning
<?php $variable1="PHP"; $variable2="MySQL"; echo $variable1."&".$variable2; ?>
Its out put will be :
PHP&MySQL
<?php $variable1="PHP"; $variable2="MySQL"; echo $variable1."<br />".$variable2; ?>
Its out put will be :
PHP
MySQL
Related Tutorials
How a PHP program look like
PHP programs are saved in a file with extension “.php” ( we can use it in .html files also ,...
Adding line break using PHP
For the formatting purpose we need to add line breaks in our output or strings to store in MySQL tables...
if statement in PHP
“if” statement is one of the most important and most used construct in PHP programming. Its syntax will look like...
PHP session tutorial
Using PHP session variable is a mechanism to store user’s data in server. And sessions will last till we are...
else statement in PHP
“else” statement is an extension with “if” statement in PHP programming. If need to execute a block of statements when...
PHP mail() – send email
PHP mail() function is used for sending emails from your website. Syntax of mail() function is : mail (to email...
for in PHP loop programming
for statement is also used to make looping in PHP programming. Its structure is bit more complex than the other...
PHP htmlentities() – convert characters to html entities
PHP htmlentities function is used for covert the characters to its HTML entities. This function will automatically identify the characters...
Echo will be one of the most used statement in PHP
Some unofficial reports saying that “echo” is faster than “print” statement in PHP