Jump to content

[SOLVED] php newb hello world broke


bluethundr

Recommended Posts

Hey guys

 

Brand new to PHP and of course my "Hello World" isn't hello worlding. Any chance you guys could have a look and let me know what the heck went wrong?  :shrug:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                      "http://www.w3.org/TR/html401/loose.dtd">
<html>
<head>
     <meta http-equiv="Content-Type" content="text/html; charset=iso-8559-1">
     <title>Hello, world</title>
</head>
<body bgcolor="#ffffff">
    
    <?php
      print "Hello, world";
    ?>
    </h1>
    </body>
    </html>

 

Definitely need the clue-by-four here.  :confused:

 

Thanks

Link to comment
Share on other sites

Oh this is interesting! I am running on Mac OS X Snow Leopard. This is the first chance I've had to mess around with PHP on it. And the phpinfo() script is not opening the traditional php info page that we all know. It just renders the text from the script in the browser window.

 

But when I type php -version it definitely appears to be installed and working.

 

mazdayasna:apache2 bluethundr$ php -version
PHP 5.3.0 (cli) (built: Aug 23 2009 12:55:35) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies

Link to comment
Share on other sites

I'm actually being a tad lazy and opening the file by going to file -> open in firefox. If I get my php install working correctly I will move my php files to the correct place on the mac and start using them there.

 

But I did manage to find this excellent PHP mac tutorial:

 

http://foundationphp.com/tutorials/php_leopard.php

 

Did everything the article said.. and no love.  :'(

 

Same as before.

Link to comment
Share on other sites

I'm actually being a tad lazy and opening the file by going to file -> open in firefox. If I get my php install working correctly I will move my php files to the correct place on the mac and start using them there.

 

But I did manage to find this excellent PHP mac tutorial:

 

http://foundationphp.com/tutorials/php_leopard.php

 

Did everything the article said.. and no love.  :'(

 

Same as before.

 

You need to visit it via localhost (while running apache & php) - not just by going to the file.

Link to comment
Share on other sites

opening it via your browser like that won't do anything, because your browser is not what parses the script.  When you go to localhost via your browser, you are making a request to a server (a local server, like when you run apache) just like when you go to a regular website. Apache and php is what actually executes and parses the script.

Link to comment
Share on other sites

Ok guys, clue-by-four has been applied to yon forehead with great success!

 

So, now opening the phpinfo.php script shows that php is working. However the code snippet I placed before renders a blank page with "Hello, world" showing in the browser title bar.

 

I think we are getting closer.

 

Thanks!

Link to comment
Share on other sites

duuuhhhh sorry guys. As I said this is exactly day 1 of my php usage. Going back to the beginning is that I was opening it wrong, and it had the wrong file name. I also had to enable php in apache on my mac.

 

So putting it in the right place, enabling php and giving it the right name worked.

 

thanks again for sticking with me on this.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.