Jump to content

Converting html to dynamic php


narjis

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.