PHP don't seeming to be working on my macbook pro

Discussion in 'Mac Basics and Help' started by smoque, Jul 29, 2008.

  1. smoque macrumors newbie

    Joined:
    Jul 29, 2008
    #1
    Hello,
    I bought a book entitled "Web Development Solutions by" Heilmann and Francis. It is a "how to" book for web development (obviously). Chapter 1 goes throught some simple code for basic web development and uses a simple PHP command to display content. The entire code is below:


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html dir="ltr" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Meeting Agenda for Friday, 30.07.2006</title>
    <link rel="stylesheet" type="text/css" href="meetingagenda.css" />
    </head>
    <body>
    <h1>Meeting Agenda</h1>
    <h2>What to do with web standards</h2>
    <p>On Friday, the following attendees will meet to discuss the importance of standardization of web communication:</p>
    <ul>
    <li id="chairman">Tim Berners-Lee</li>
    <li>Linus Torvalds</li>
    <li>Tantek Celik</li>
    <?php if (isset ( $_Get['commercial' ])) {?>
    <li class="commercial">Bill Gates</li>
    <li class="commercial">Steve Jobs</li>
    <?php } ?>
    </ul>
    <?php echo '<p id="footer">© Awsomemeetings.com 2006, Last Modified:' . date ('F d Y H:i:s .', getlastmod()) . '</p>' ?>
    </body>
    </html>



    When this file is saved as a .html file, I can view it in my browser and everything is working correctly except the PHP line. When I save this file as a .php file, the source code is displayed. According to the book, this should not be happening, the "echp" command should be showing the date last modified.

    I am VERY new to web development and am totally lost at this point. Can anyone help me please?
     
  2. a456 macrumors 6502a

    a456

    Joined:
    Oct 5, 2005
    #2
    PHP is something known as server-side scripting. It needs to be hosted on a web server in order to work - don't ask me why, I'm not that technical either. The easiest way to get server-side scripting functionality on your local hard drive is to install MAMP (http://www.mamp.info/en/index.php), there are harder ways but I won't go into them since you're a novice.
     
  3. smoque thread starter macrumors newbie

    Joined:
    Jul 29, 2008
  4. baummer macrumors 6502a

    Joined:
    Jan 18, 2005
    Location:
    Southern California
    #4
    PHP isn't installed in OS X by default. If you have web hosting, 99% of hosts have PHP installed and configured. You can easily install PHP into OS X though.
     
  5. smoque thread starter macrumors newbie

    Joined:
    Jul 29, 2008
    #5
    I loaded MAMP and the same thing is happening. Perhaps I missed something?
    On the start page, there is a messge that says "If you can see this page, MAMP is installed on your MAC and everything is working!", which is not the case.


    rjt
     
  6. baummer macrumors 6502a

    Joined:
    Jan 18, 2005
    Location:
    Southern California
    #6
    You need to save your .php file in the root folder of MAMP. Do this:

    1. Go to Applications > MAMP > htdocs
    2. Create a folder (e.g. test or projectname)
    3. Save .php file in the folder you created
    4. Launch your browser and point it to http://localhost:8888/folderyoucreated/fileyousaved.php
     
  7. smoque thread starter macrumors newbie

    Joined:
    Jul 29, 2008
  8. cleo macrumors 65816

    cleo

    Joined:
    Jan 21, 2002
    Location:
    Tampa Bay Area, FL, USA
    #8
    Just to clarify for future searchers, PHP is installed by default with Leopard; it's just not turned on.

    This site is a great intro to setting up a development environment on your Mac.
     

Share This Page