Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

smoque

macrumors newbie
Original poster
Jul 29, 2008
17
0
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?
 
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.
 
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.
 
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
 
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

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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.