narjis Posted February 15, 2011 Share Posted February 15, 2011 I got and assignment to convert html with<divs> and <ul><li>,css, js and all to be converted to php. I know simple programs but how do I convert this type of index.html to dynamic php. I saved it as index.php but want to manage heders and footers. Can anybody help me. Quote Link to comment Share on other sites More sharing options...
trq Posted February 15, 2011 Share Posted February 15, 2011 We don't do homework. Where exactly are you stuck? Quote Link to comment Share on other sites More sharing options...
narjis Posted February 15, 2011 Author Share Posted February 15, 2011 I have an index.html with tables and div tags, headers defined in css too. How can I convert them to header.php and footer.php.If there is any guiding book for converting Html to PHP please guide me to it. Thanks Quote Link to comment Share on other sites More sharing options...
haku Posted February 15, 2011 Share Posted February 15, 2011 It's not a matter of conversion, they are different things. PHP is a programming language - think of the synapses in your brain. HTML is a markup language - think of the words that come out your mouth. The synapses create the words, but you can't convert the words to synapses. To put it simplest, to covert HTML to PHP, you change the name of your file from something.html, to something.php. And you are done. But, to put it another way, if your file looks like this: something.html <html> <head> // head stuff </head> <body> // body stuff <div id="footer"> // footer stuff </div> </body> </html> Then you could convert it to four .php files if you want: head.php <head> // head stuff </head> body.php <body> //body stuff <?php include(footer.php); ?> </body> footer.php <div id="footer"> // footer stuff </div> index.php <html> <?php include(header.php); ?> <?php include(body.php); ?> </html> Note: this is all purely example. It shouldn't be used verbatim - there are problems with it, such as no doctype. It's just to give an idea of how code could theoretically be converted from HTML to PHP - but with the above example there is absolutely no benefit in doing so. Quote Link to comment Share on other sites More sharing options...
narjis Posted February 15, 2011 Author Share Posted February 15, 2011 Thanks it was a great help. I've seperated my header in header.php. In the div tags if <div class="header">blahbhjka </div> is defined and header is css class here i'm putting <?php echo "<div class='".header."'">blahblah balkj</div>"; It gives an error unexpected T_STRING, expecting ',' or ';' where am I doing wrong Quote Link to comment Share on other sites More sharing options...
haku Posted February 15, 2011 Share Posted February 15, 2011 That's a question for the php forums. But check your quotes - you have a problem in there. Anyways, this thread has been answered, so if you have any more questions on another topic, you should open threads in the correct forum on that topic. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.