Is it possible to convert a HTML page to PHP?

No exactly sure what your problem/reason for this is. So excuse my ignorance if im wrong or underestimating your understanding.

Anyways if u wanted elements on a web page in HTML (such as buttons, forms etc) to be coded in PHP you would have to echo these out anyways so they would still be in HTML.

Eg. a HTML page may begin with the following code... giving the file a title...

<html>
<body>
<h1> title..... </h1>


If you wanted to create the page title in PHP you would have to echo it out something like the following...

<?php

echo "<html>";
echo "<body>";
echo "<h1> title....... </h1>";

Which is really pointless, as your doing exactly the same thing, just with more code.

If you just want to have a PHP page (convert index.html to index.php) which also contains the HTML/web page elements, just rename the page .php, and open and close your php tags in the code when you wish to jump between php and html code. Both can exist in the one file.

For example... the following file could be called 'index.php'

<?php

//SOME PHP Functionality... DBQuerys etc....
......
..
.
?> //close php

//now continue with the HTML page code

<html>
<body>

<h1> example web page </h1>

<?php

//Some more pho code if you like....
...
..
.
?>//close php code

//Contunue with HTML....



All the HTML will be displayed in the web page. PHP will only have an effect on the output/web page if you are using Echos.
 
Back
Top