Echo with HTML
As We Shown in previous program, echo is used for display the String Statement. In this section we discussed Echo statement with proper HTML Tags. As resulted we can write an HTML code inside the Echo Statement. Here is the Example
<?php echo "<h2>Welcome to Songsbuddy.com</h2>"; ?>
Welcome to Songsbuddy.com
In above program, Echo is used with proper Header tag in HTML. The Output is displayed as like as HTML output.Note:
|HTML Tags must be enclosed with Single Quotes( ' ) or Double Qoutes( " ) in Echo Statement.|
Append PHP Variable with String
We can add an HTML code to php Variable or it's Value. Look at the below Example..
<?php $a = "Hello"; echo $a."<strong>Welcome to PHP</strong>"; ?>
Here 'a' is a PHP variable and the String 'Hello' is assigned to that Variable. In echo Statement, The value of a is added to the HTML Code. In between these two we have used the Symbol dot ( . ). This dot is used to append PHP code with HTML code.
Adding two HTML Tages by Using Echo
In above Example we add the value of a variable to HTML Tag. In this Section learn how to add two HTML Tags by using Echo Statement. Let us see the Example below..
<?php echo "<strong>Statement1</strong>"."<strong>Statement2</strong>"; ?>