MrHopko MrHopko - 8 days ago 4
PHP Question

PHP not rendering in HTML

I am using Windows 7 with IIS 7.
I am trying to get started with PHP. I have performed the following:


  1. Installed PHP using the web platform installer

  2. Verified that PHP is installed by using 'Check phpinfo()' on the PHP manager within the root folder of my website (all on my local machine)



When I test to see if PHP is working with a simple HTML page as follows:

<!DOCTYPE html>
<html>
<body>

<?php
echo "My first PHP script!";
?>

</body>
</html>


Chrome does not render anything. I am expecting to see the text.

Can anyone advise me how to proceed?

Thanks

Answer

If this problem ocurrs check:

  • Does the file have extension .php?
  • Does the path is correct on the server?

Its is important to remember that I am assuming that you have a server with php suport activated. On the server, the default extension to PHP files is .php, but you can check with the administrator to garantee.

You can also check if the error log is enable. When it is disabled, and the code has a syntax error, nothing is showed on the screen. You can read more here: https://stackoverflow.com/a/5438125/1735789