开发者

Basic PHP Problem

I've been going through some of the tutorials on php.net, and I've been encountering something unexpected and don't have enough knowledge of php (or even the new versions of HTML) to really understand what's going wrong. I am following this: http://www.php.net/manual/en/tutorial.firstpage.php. To my knowledge, I have followed everything to the letter. The code for "index" in my htdocs folder is as follows:

    <html>
     <head>
       <title>PHP Test</title>
     </head>
开发者_开发知识库     <body>
      <?php echo '<p>Hello World</p>'; ?>
     </body>
    </html>

But the resulting text when I go to http://localhost/ is this:

Hello World

'; ?

What am I doing wrong? Is PHP perhaps installed incorrectly? How can I check and make sure?


Save the file as 'index.php'. I get the same problem you describe when I save your code as 'index.html'.

If PHP is working, you should see this when you 'view source' for your web page:

<html>
 <head>
  <title>PHP Test</title>
 </head>
 <body>
  <p>Hello World</p>
 </body>
</html>

[PS: Fastest way I know to get going with PHP is to download 'WAMP Server' (Google it), run the installer, click next-next-next-next... and start writing and saving your PHP scripts in 'C:\wamp\www'. You might need to uninstall IIS or whichever webserver you've currently got installed, or change the Apache port number of your WAMP installation... although from your question it sounds like you might be on a Mac?]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜