|
|
|
HTML to PHP Converter for integrating templates |
We have to integrate HTML code inside PHP script to display the pages to
browser after proper formatting. For this we have to convert HTML code to PHP
script and display or return them to browser. This is very much required when we
have to integrate a PHP script in a HTML template. 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 and
display the HTML tags. The second way is not advisable for large
pages with more code as that will slow down the page as each time script has to
transit from PHP to HTML mode. 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
<?
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.
<?
echo "<table width=\"100%\"
border='0' cellspacing='1' cellpadding='0'>";
?>
This way any number of HTML tags can be converted to PHP code
| |
| Subscribe |
|
Submit your email address and receive
article and product notifications. Your email is safe with us.
|
|
|
|
|
|