Saturday, July 29, 2017

php echo() function

PHP Echo statement is basically use to print the content in browser webpage. Here we will learn small concept about the Echo with examples.




The syntax of PHP is as follow :

void echo ( string $arg1 [, string $... ] )


Echo :

1. Echo is a statement. The purpose of echo statement is to display output in webpage.
2. It can be used with parentheses echo or without parentheses echo.
3. Echo can pass multiple string separated as ( , ) OR (.).
4. Echo doesn’t return any value.
5. Echo is faster than print.

Printing String using php echo :
<?php  
echo "Printing the text using php echo";  
?>

Output :
Printing the text using php echo

Printing Variable using php echo :
<?php  
$var="Printing the variable using php echo";  
echo "Variable is: $var";    
?>

Output :
variable is : Printing the variable using php echo

Pass Multiple Argument using php echo :
<?php
 
$name = "Skptricks ";
 
$role = "Developer ";
 
$salary = 260000;
 
echo $name , $role , $salary; // we can concat variable/string using (,) OR (.)
 
?>

Output :
Skptricks Developer 260000

Printing Escaping characters using php echo :
<?php  
echo "Hello escape \"sequence\" characters";  
?>

Output:
Hello escape "sequence" characters



No comments:

Post a Comment