Inserting a PHP Variable into HTML Code
Suppose now we have a paragraph, above which a PHP variable is defined:
<?php
$str = 'text';
?>
<p>text</p>
We can insert our variable inside the paragraph:
<?php
$str = 'text';
?>
<p><?php echo $str; ?></p>
Or we can simplify the variable insertion using a short PHP tag:
<?php
$str = 'text';
?>
<p><?= $str ?></p>
Three variables are given:
<?php
$str1 = 'text1';
$str2 = 'text2';
$str3 = 'text3';
?>
Also, three paragraphs are given:
<p></p>
<p></p>
<p></p>
Insert the text of the variables into the corresponding paragraphs.