Newbie PHP Question

Discussion in 'PHP' started by lv211, Feb 6, 2007.

  1. #1
    So I installed Easy PHP on my computer. How do I get php files to execute in my browser?

    When I open them right now it asks me what program I want to use instead of executing the code.
     
    lv211, Feb 6, 2007 IP
  2. evera

    evera Peon

    Messages:
    283
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Make sure everthing is running: Apache, MySQL and PHP
    You can check that by typing http://127.0.0.1 or http://localhost in your Browser.
    Then you could make an .html file with something like this:

    <html>
         <head>
         <title>My First page in PHP</title>
         </head>
         <body>
         
         Current date : <?php print (Date("l F d, Y")); ?>
         
         </body>
         </html>
    HTML:
    If it is working you are done.
    Now you have to read some books and manuals about .php, Apache, and MySQL. :D
     
    evera, Feb 6, 2007 IP
  3. JoshuaGross

    JoshuaGross Peon

    Messages:
    411
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Don't you mean .php?
     
    JoshuaGross, Feb 6, 2007 IP
  4. evera

    evera Peon

    Messages:
    283
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    No I meant .html
    But this is just to test it. There is a php script init:
    <?php print (Date("l F d, Y")); ?>
    PHP:
    If it is working you know you have everything set up correct.
    And then you can make your .php files.
     
    evera, Feb 6, 2007 IP
  5. Icheb

    Icheb Peon

    Messages:
    1,092
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It's pointless to create a .html page with PHP code. It's unlikely that Apache will be configured out of the box to parse .html as PHP so all it will do is output PHP code.
     
    Icheb, Feb 6, 2007 IP
  6. evera

    evera Peon

    Messages:
    283
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #6
    No its not pointless. It does its job.
    Because its just an example to test his configuration, which is his problem I guess.
    I even took it from the online installation manual of easy php ;)
     
    evera, Feb 6, 2007 IP
  7. Icheb

    Icheb Peon

    Messages:
    1,092
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I guess an Apache server configured to parse .html as PHP has to be expected with something called "Easy PHP". :rolleyes:
     
    Icheb, Feb 6, 2007 IP
  8. JoshuaGross

    JoshuaGross Peon

    Messages:
    411
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #8
    If he ever wants to learn it well - EasyPHP may be a good intro but putting PHP in .html files is horrible practice. I learned with Xitami and later XAMPP - I'm not saying that software is bad to use. But mixing file extensions can be a nightmare, and it should be avoided as soon as possible.
     
    JoshuaGross, Feb 6, 2007 IP
  9. evera

    evera Peon

    Messages:
    283
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I think you missunderstood me. I'm not saying it parses .html as .php it just execute the script in the .html as php, just to check that its working.
    And that does every php environment.
    And if you ask me a decent Deabian LAMP would prevent such problems at all.
     
    evera, Feb 7, 2007 IP
  10. Icheb

    Icheb Peon

    Messages:
    1,092
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #10
    And how is one different from each other?
     
    Icheb, Feb 7, 2007 IP
  11. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #11
    Icheb is right, unless apache or your server daemon is configured to execute php inside .html files it will not work.
     
    krakjoe, Feb 7, 2007 IP
  12. lv211

    lv211 Peon

    Messages:
    168
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #12
    I'm going to check this out.

    Thanks for your help guys.
     
    lv211, Feb 7, 2007 IP