Page 1 of 1

Complete newb question (.php vs .html file)

Posted: Mon Sep 20, 2010 5:30 pm
by djarv
I'm having a few problems understanding how PHP is integrated with HTML (and/or vice versa); the problem seems to be too much information on the web sometimes.

Anyway, I found this small snipped of code where it was implied that it would run as a .php or .html file but that seems not to be the case. The .php file works fine (outputs five lines of 'Menu Item N'); the .html outputs only one line ('Menu Item').

So my question is: why doesn't the html version work?

<html>
<head></head>
<body>
<ul>
<?php for($i=1;$i<=5;$i++){ ?>
<li>Menu Item
<?php echo $i; ?>
</li>
<?php } ?>
</ul>
</body>
</html>


Thanks for bearing with my newbieness.

Re: Complete newb question (.php vs .html file)

Posted: Mon Sep 20, 2010 7:21 pm
by requinix
PHP won't execute the file unless you give it a .php extension. There are ways around this but for now just use the right file extension.