Shoutbox

HTML > PHP - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: HTML > PHP (/showthread.php?tid=68921)

HTML > PHP by Eddie on 11-28-2006 at 01:55 PM

Hello everyone, i have made a page in HTML that actually needs to be coded in php, is there a way to easily convert the code?? :S


RE: HTML > PHP by xJ + on 11-28-2006 at 02:00 PM

You might want to try this


RE: HTML > PHP by Adeptus on 11-28-2006 at 02:03 PM

There is nothing to convert.  PHP pages still contain HTML.  PHP is nothing more than a way to enhance an HTML page with some code that will execute server-side when the page is requested by the browser.  So, all the "conversion" it takes is changing the extension to ".php". 

Of course, you will still need to add the PHP code to do what you want it to do.  Although somewhat dated, you may find this tutorial helpful in that task.


RE: HTML > PHP by RaceProUK on 11-28-2006 at 03:21 PM

And of course there's php.net, which has the full documentation for all of PHP.


RE: HTML > PHP by absorbation on 11-28-2006 at 04:56 PM

HTML and PHP are very different. HTML is used for your browser to pick up on read-able code and form objects using it, which is what you see on your screen. PHP is a server addon designed to allow dynamic content. It basically is a web server language, in a syntax similar to C.

PHP 'echos' or 'prints' HTML code using a variety a formulas to decide what HTML for the web server to load into your browser. A simple example of this is check the day of the week. A simple peice of PHP code can be used to check the date:

code:
<?PHP
$date = date('D');

if ($date == 'Mon')
{
     echo "It's monday";
}

else
{
     echo "It is not Monday";
}
?>

Of course you can't do this with HTML. PHP is something needed to be installed on a server, whereas HTML code is something all up to your browser. The 'echo' used shows the HTML code like you would normally, but the PHP checks to see what code should be echoed :P


Edit: There is no such thing as converting HTML to PHP, and your best chance is to post your HTML page and explain what is not working ;)
RE: HTML > PHP by RaceProUK on 11-28-2006 at 07:18 PM

You can also do dynamic content with HTML, by leveraging JavaScript, but the beauty of PHP is that your code remains hidden from the browser.

And

code:
It is <?php if (date("D") !== "Mon") {?>not <?php }?>Monday
is a little more efficient. Though a little harder to read.

Edit: :P @ Mike
RE: HTML > PHP by Mike on 11-28-2006 at 07:21 PM

quote:
Originally posted by RaceProUK
but the beauty of PHP is that your code remains hidden from the browser.
And, that the user doesn't need to have Javascript enabled to see the website ;)
RE: HTML > PHP by rav0 on 11-30-2006 at 10:33 AM

quote:
Originally posted by Shadow
Hello everyone, i have made a page in HTML that actually needs to be coded in php, is there a way to easily convert the code?? :S

Rename the Page to end in ".php". When it's requested by a browser, it'll come out exactly the same (unless there are PHP start marks ("<?php" or "<?" with short tags enabled in PHP) in the page code).

You can add bits of PHP where they need to go into the existing code.

This post looks long, but it's simple and only looks long because there's lots of space. Have a read of the examples below.


awesome.html:
code:
<html>
<body>
The date is 2006-11-30. It is a Thursday.
</body>
</html>
gives:
quote:
The date is 2006-11-30. It is a Thursday.

awesome.php:
code:
<html>
<body>
The date is 2006-11-30. It is a Thursday.
</body>
</html>

gives:
quote:
The date is 2006-11-30. It is a Thursday.

awesomer.php
code:
<html>
<body>
The date is <?php date(Y-m-d) ?>. It is a <?php date(l) ?>.
</body>
</html>

gives:
quote:
The date is <the date now>. It is a <whatever day today is>.