Syntax:echo "This is GeeksforGeeks Tutorial."; echo variable_name;
Note.The echo command will print an HTML document. This function can be used to place JavaScript statements in an HTML page.
Example 1:This example illustrates how to use the echo keyword to display content.
// Declare the variable and save the string
$var1
=
" GeeksforGeeks "
;
$var2
=
"A computer science portal "
;
// Use the echo keyword to display the result
echo
$var1
.
""
.
$var2
;
?>
Output:GeeksforGeeks A computer science portal
Point. The operator is used to concatenate two strings in PHP. You can print multiple variables by connecting them with a "." operator. The echo keyword is used to display the values of var1 and var2 in an HTML document that is usually read by a browser. This property can be used when writing to the JavaScript console using PHP. JavaScript code can be written in an echo section and transferred to an HTML document.Example 2:This example illustrates how to print a string to the console.
// Use the echo keyword to display the result
echo
"Open console and check"
;
echo
’ ’
;
?>
Output: Now we’ll see how to write the value of PHP variables to the console string.Example 3:This example illustrates how to print the value of PHP variables to the console.
// Declare the variable and save the string
$var1
=
" GeeksforGeeks "
;
$var2
=
"A computer science portal "
;
echo
" Open console and check "
;
echo
’ ’;
?>
Output: