ocanyc Posted July 10, 2007 Share Posted July 10, 2007 So I finally setup an apache server, with php and mysql on windows. This is for fun and learning btw. I'd like to get into php programming now. I was following some tutorial where it had me write a simple script. Just a display in the browser. Here is my question because at first it didnt work, when I opened the php file from the browser. I'm hoping this is a simple question for you guys using apache servers. Basically this works..... http://localhost/easy_script.php And I get the display I'm suppose to see: Agent: So who do you think you are, anyhow? Neo: I am Neo, but my people call me The One. This doesnt: file:///C:/Public_Html/Easy_Script.php I only get this part: Agent: So who do you think you are, anyhow? Here is the script code: <html> <head></head> <body> Agent: So who do you think you are, anyhow? <br /> <?php // print output echo 'Neo: I am Neo, but my people call me The One.'; ?> </body> </html> My main question is, why does php work when I open it using my localhost address. But when opened as a file in the browser it doesnt. Is there something I should check in the php.ini file, or the Apache httpd.conf file? Seems it should work both ways?Thanks in advance. Quote Link to comment Share on other sites More sharing options...
trq Posted July 10, 2007 Share Posted July 10, 2007 This is completely normal. Accessing the file via http://localhost means that your apache server serves the request, hence your php is executed. Simply opening the file via file:// does not execute the php. PHP is executed at the server. This is the entire reason you installed a server in the first place. Quote Link to comment Share on other sites More sharing options...
ocanyc Posted July 10, 2007 Author Share Posted July 10, 2007 Well thank you. Told you I was a newb heh. I'm sure this forum will be very helpful with my future questions. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.