Jump to content

Converting html to dynamic php


narjis

Recommended Posts

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.