Okay, this is kind of embarrassing. I am an extreme noob in php, and have just started learning. The trouble is, I can't get it to work on my mac. For example, if I want to run some of the code in Safari (I have OS X 10.6), it will just display the text of the code, instead of actually running it. Does anybody here know how to install and run PHP on a mac?
I'm not really familiar with mac, but the problem with mac is that it isn't really made for hosting PHP scripts and development of PHP scripts, it's made for noobs so everything pretty much "just works". In any case, maybe this will help. I did it for you.
hahaha very funny. i googled it first, went through a $@#!-load of crap in terminal and textwrangler, and I ended up doing, well, not much. but thanks for the funny reply. i needed that.
sounds like apache is running, general debugging process, did you restart the apache process after installing php? is there a php.ini file? has apache got the module? is the module loaded? your php file using <?php and not "<?"? <?php phpinfo();?> return anything? failing that just create a ubuntu virtual server and quick install lamp. That will be done in an hour or so, rather then spending your time debugging
Well, that's what you get with mac.. lol It's very easy with windows or linux. If you don't want to go through all that crap, why not just get a webhost?
Have you tried MAMP? I'm on Windoze and Linux, so I've never used it, but if it's anything like WAMP or LAMP, it'll set up Apache, MySQL and PHP for you automagically.
I use MAMP. Unfortunately it isn't working. I had the test.php file located at the correct root, and I typed in http://localhost/ into my browser, and yes, apache is working fine. I also edited the httpd.conf file (I took away the # from some of the lines) like it says on other sites, and the php.ini problem doesn't apply in Snow leopard. Is there something that I'm missing? Why wont my mac parse the php correctly?
oh, also mac comes presintalled with php, while in windows you need to install it manually so it should be just as easy or easier than in windows to run php on mac. ahhh...with everything I try to do with computers theres always a host of problems in the way
Mac is not "made" for noobs. Atleast know what you're talking about before making such a ridiculous assumption like that. I use windows, mac and linux in a tri-boot. Each serves it's own purpose, but I rather do everything on linux If I can, such as running Xcode and photoshop on it.
Agreed. I got a mac specifically because I spent more time trying to get my windows to work than actually use it. I am a noob when it comes to php, but overall, i am not a noob in computers.
photoshop on linux is working fine now. same can't be said for xcode, I would be tempted to run os x as a virtual machine inside linux, less switching todo and more time in linux
Don't mean to interrupt this mac discussion or is it about php ? LOL But could you post up the full code your trying in the test.php file from <?php
I don't know if I should argue with you or not man... lol Thank you. Thank you for supporting me. Both.
Here's the code. I found it on the internet and its a very good test page for php. I also have a very basic file called hello php which is just <?php echo "hello"; ?>. <?php /* Original code by Erwin Poelman found on http://www.weberdev.com/get_example-3096.html This is a little more up to date and formatted for readability. Some things in PHP have changed since Erwin Poelman first posted this and a couple of things had to be added to resolve variables that are no longer automagically (yes, I spelled it right! set. Also added a test for <?...?> enclosure. Changed the hard coded file name (originally 'generate.php') in the src attributes to server resolution through the 'PHP_SELF' value. Otherwise, its a pretty neat and tidy little browser PHP interpretter, just as Erwin Poelman originally wrote it! */ if(isset($_REQUEST['dispArea']))$dispArea=$_REQUEST['dispArea']; if(isset($_REQUEST['theCode']))$theCode=$_REQUEST['theCode']; if(!isset($dispArea)) { echo "<frameset cols='60%,40%'>\r\n"; echo "<frame name='theCode' src='".$_SERVER['PHP_SELF']."?dispArea=left'>\r\n"; echo "<frame name='theExec' src='".$_SERVER['PHP_SELF']."?dispArea=right'>\r\n"; echo "</frameset>\r\n"; } else { if(!strcmp($dispArea,"left")) { echo "<body bgcolor='#D0DEED'>\r\n"; echo "<font face='Arial,Verdana,Helvetica' color='FF0000' size='3'>PHP Tester</font>\r\n"; echo "<form method='post' action='".$_SERVER['PHP_SELF']."?dispArea=right' target='theExec'>\r\n"; echo "<table>\r\n"; echo "<tr><td align='center'>\r\n"; echo "<input type='submit' value='Execute'>\r\n"; echo "</td></tr>\r\n"; echo "<tr><td>\r\n"; echo "<textarea name='theCode' cols='65' rows='25' wrap='virtual'>\r\n"; echo $theCode."\r\n"; echo "</textarea>\r\n"; echo "</td></tr>\r\n"; echo "</table>\r\n"; echo "</form>\r\n"; } else if(!strcmp($dispArea,"right")) { echo "<body bgcolor='#FFFFFF'>\r\n"; if(empty($theCode)) { echo "Ready to parse..."; } else { $theCode=ltrim(rtrim(stripSlashes($theCode))); if(!strncmp($theCode,"<?",2)) //if it's full php, remove the tags { if(!strncmp($theCode,"<?php",5)) { $theCode=substr($theCode,5); } else { $theCode=substr($theCode,2); } $theCode=substr($theCode,0,strlen($theCode)-2); $theCode=ltrim(rtrim(stripSlashes($theCode))); } eval($theCode); } } echo "</body>"; } ?> Anyways, I tried XAMPP and it's very similar in idea to MAMP. Still doesn't work, and I prefer MAMP to tell you the truth. Meh...im having an easier time learning php than actually getting the computer to parse it.
OMG!! I installed WAMP on my windows partition, and gues what? it worked! now if only i could understand the connection between mysql and php. this stuff is hard to wrap my head around...