PHP Echo

PHP Echo

PHP Echo

In PHP, echo is a language construct that is used to output one or more strings to the browser or to the command line. The basic syntax of the echo statement is:

				
					echo "string to be printed";
				
			

Here, “string to be printed” can be a string literal or a variable that contains a string value.

For example:

				
					<?php
$name = "John";
echo "Hello, " . $name . "!";
?>

				
			

In this example, the echo statement outputs the string “Hello, John!” to the browser.

You can also use the echo statement to output multiple strings separated by commas:

				
					<?php
echo "Hello, ", "world!";
?>

				
			

In this example, the echo statement outputs the string “Hello, world!” to the browser.

The echo statement is often used in PHP to display dynamic content, such as the result of a calculation or the value of a variable. It is a quick and easy way to output text to the browser or to the command line.

Join To Get Our Newsletter
Spread the love