tags:

views:

28

answers:

1
<HTML>
<HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <TITLE></TITLE>
</HEAD>
<BODY>
    <?php echo '<p>Hello World</p>'; ?>   
</BODY>
</HTML>

When I run the above code in a browser, firefox renders it like this:

Hello World

'; ?> 

I am doing my coding in Windows XP/IIS 5.1. I have PHP set up correctly because I have no problem running .php files. The problem, it seems to me, is that IIS can't render php code embedded inside html. Does anyone know how to fix this problem or should i switch to Apache?

edit: the file extension is .html

+1  A: 

You need to tell IIS to run your .html files through the PHP interpreter rather than serving them directly.

I'm not sure how one does that ... a little googling turned up this:

N.B. / Caveat emptor What follows is taken from the Microsoft Support site and the answer is for setting up IIS with Perl -- I believe that it should also work for PHP, or at least start you on the right track, but I haven't tested it as I don't have IIS.

Click Start, click Programs, click Administrative Tools, and then click Internet Information Services. Right-click a Web site that you want to enable PHP for, and then click Properties. Click the Home Directory tab. Click Configuration. Click Add. Type the following for Executable: full path to php.exe\php.exe %s %s Note The "%s %s" is case sensitive (for example, "%S %S" does not work). For Extension, type .html.

Note Make sure that the All Verbs option is selected for full functionality. Also, make sure that the Script Engine check box is selected. Click OK to return to the ISM. With the default scripts directory with IIS, the URL is the following: http:// Server Name/scripts/helloworld.html

Sean Vieira