The Echo statement
- It is also a statement used to display output in PHP.
- It doesn't return value.
- It allows passing multiple arguments which are separated by a comma.
- Like that of print, echo can be used with or without parenthesis.
- It is faster than a print statement.
Example 1: Echo statement with and without parenthesis
<?php echo "Hello world without parenthesis"; //without parenthesis echo "<br>"; echo ("Hello world with parenthesis"); //with parenthesis ?>
Example 2: Displaying value of variables using echo.
<?php $fname="John"; echo "Fname:".$fname; ?>
<?php $fname="Tedy"; $lname="Kassashun"; echo "Full Name:".$fname,$lname; ?>
<?php $city="Adisababa:"; $coun=echo $city."Is the capital city of Ethiopia"; echo "<br>"; echo "value Returned:".$coun; ?>
0 Comments