HTML to PHP Converter for integrating templates

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.

There are two ways to do this. One way is to echo or print the html tags inside the PHP code and the second way is to close the PHP script execution area and return to HTML mode to display HTML tags.

Displaying HTML tags outside PHP script tags

Without keeping both together we can keep both in different areas so PHP engine does not come across HTML tags. However this is not practicable and is not a good idea for developing complex applications. Here is a sample code for this.

<?Php
// PHP script area
?>
<br> this is " our HTML area " we can use any tags or chars as we like "

Displaying HTML tags inside PHP script

By printing the same HTML code from inside the PHP code we can get same result and comparable less load or delay in file execution. But in this case we have to take care some points as double quotes inside echo Command of a PHP script is not allowed. The code below will generate error as we have kept double quotes inside the PHP script area

<?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'>";  
?>


This way any number of HTML tags can be converted to PHP code

Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com




    Post your comments , suggestion , error , requirements etc here .




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer