I would like to learn how to write php...

Discussion in 'PHP' started by chengcj, May 9, 2006.

  1. #1
    I have wrote the following php in a notepad:

    <html>
    <head>
    <title>PHP Test</title>
    </head>
    <body>
    <?php echo '<p>Hello World</p>'; ?>
    </body>
    </html>

    I saved it as hello.php, then I use IE to open the file but nothing happens=_=

    I have installed php 5, do I need to configure anything on my computer so that I can open php files on my computer?
     
    chengcj, May 9, 2006 IP
  2. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The code is correct so my guess is you have no working Apache server on your machine. What do you get when you browse to http://localhost ?

    Google for 'download PHP MySQL Apache' or similar and get one of those packaged deals that install all you need and talk you through setting it up.

    http://www.wampserver.com/en/download.php for instance.
     
    T0PS3O, May 9, 2006 IP
  3. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Forget installing PHP, Apache and MySQL separately.

    Do yourself a favour and install XAMPP for Windows from apachefriends.org.

    Remember: PHP is a server side scripting language. It needs to be interpreted by a web server (eg. Apache running on localhost). Web browsers themselves don't interpret PHP scripts.
     
    TwistMyArm, May 9, 2006 IP
  4. chengcj

    chengcj Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thank you very much!

    I have installed xampp

    But I still don't know how to run my hello.php? Do I need to put hello.php to a certain directory? And then run it through the cmd console?
     
    chengcj, May 9, 2006 IP
  5. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #5
    TwistMyArm, May 9, 2006 IP