How to use HTML attributes in PHP echo statement

Notes:

HTML attributes inside PHP

W.K.T. We can directly insert HTML tags in between single/double quotations as part of the PHP strings to generate desired HTML structure.
While inserting HTML tags in between single/double quotations of PHP string, we need to be careful about assigning values to HTML attributes.

If you want to use double quotations inside pair of double quotations, must use \ character to escape the inner double quotations.

If you want to use single quotations inside pair of single quotations, must use \ character to escape the inner single quotations.

If you don’t want to use escape character then you can mix and match
i.e.
Use single quotations inside when double quotations are used to make a string
Use double quotations inside when single quotations are used to make a string

Example Code:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Default page</title>
</head>
<body>
<?php
echo "Hello <font color=\"red\" size=\"5\">World</font> <br/>";
echo 'Hello <font color=\'red\' size=\'5\'>World</font> <br/>';
echo "<br/>";
echo "Hello <font color='red' size='5'>World</font> <br/>";
echo 'Hello <font color="red" size="5">World</font> <br/>';

?>

</body>
</html>

You can use whichever is convenient.

Interview Questions:

1. PHP stands for ______________
a. Hypertext Preprocessor
b. Preprocessor Hypertext
c. Personal Home Processor
d. Personal Hypertext processor
Ans: a