<?php
$title = 'Account';
$safeTitle = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
?>
<h2><?= $safeTitle ?></h2>
<p>This markup is ordinary HTML outside the PHP block.</p>
We can integrate HTML code inside PHP script to display the pages in web browser after proper formatting. After all our browser does not understand PHP and it can only understand HTML tags. So to Keep HTML tags inside PHP script we need to make it compatible to PHP. This is very much required when we have to include PHP script and HTML both in same page.
<?Php
// PHP script area
?>
<br> this is " our HTML area " we can use any tags or chars as we like "
<?Php
echo "<table width="100%" border='0' cellspacing='1'
cellpadding='0'>"; // Double quotes inside this line not allowed.
?>
There are two ways to solve this . One is to use single quotes in place of double quotes or to use PHP escape command ( \ ) to tell PHP not to consider the
character next to it while evaluating. Here is the correct code using escape
command.
<?Php
echo "<table width=\"100%\"border='0'
cellspacing='1' cellpadding='0'>";
?>
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.