Elemental Posted March 28, 2010 Share Posted March 28, 2010 Hey Folks, I have the following webpage document I use to learn and play around with named "learning_playing.html" (yeah, I know, very creative) on my local hard drive and I recently changed the extention to PHP to see what the differences would be...Why is it, if I save this document as ANSI or UTF-8 with an HTML extention I can open it as webpage with either IE or FF but if I save it with a PHP extention I can only open it with IE; FF opens a text document?Peace,Elemental Link to comment Share on other sites More sharing options...
boen_robot Posted March 28, 2010 Share Posted March 28, 2010 PHP files need to be opened from a web server. Opening them up from your local hard driver, without a web server on your computer will mean that your browser has no idea what PHP is (unless you explicitly tell your computer that files with a ".php" extension are equivalen to files of ".html" extension*). The only difference in behaviour you observe is what browsers do with unknown file types - IE lets you download it, Firefox displays it as plain text.*Even if you do explicitly tell your computer what a PHP file is, you still won't be able to actually execute the PHP code in the files. You need the PHP interpreter for that, and that interpreter (usually?) needs to run from a web server on your computer, or on a remote web server, with its own copy of the interpreter. Link to comment Share on other sites More sharing options...
Elemental Posted March 28, 2010 Author Share Posted March 28, 2010 PHP files need to be opened from a web server. Opening them up from your local hard driver, without a web server on your computer will mean that your browser has no idea what PHP is (unless you explicitly tell your computer that files with a ".php" extension are equivalen to files of ".html" extension*). The only difference in behaviour you observe is what browsers do with unknown file types - IE lets you download it, Firefox displays it as plain text.*Even if you do explicitly tell your computer what a PHP file is, you still won't be able to actually execute the PHP code in the files. You need the PHP interpreter for that, and that interpreter (usually?) needs to run from a web server on your computer, or on a remote web server, with its own copy of the interpreter.boen_robot, Thank you for your reply, much appreciated.justsomeguy had mentioned the server thing to me but my confusion came when I was able to open the same file using the save as ANSI and not UTF-8 with the PHP extension.This came about when I created a new page "testing.php" gave it the PHP extention but did not save it as UTF-8 but rather as ANSI, which is the default setting, my surprise when FF was able to open it and I couldn't figure out why.I then copied and saved the original file (learning_playing.html) into a new folder, changed the extension to PHP and opened both as text and went line by line to see if anything "visually" had changed to cause this to happen; obviously the answer was no.Then, for no other reason than because something told me to, I went to the save as options... The original file "learning_playing.html" was UTF-8 the copy "learning_playing.php" was UTF-8 as well of course but the newly created file testing.php was ANSI. When I saved the copy of the original "learning_playing.php" as an ANSI file FF was able to open it with out a problem, thus my post.I'll look into the file association but all of my php files open with notepad, I have to right-click and choose open with IE or FF etc.Peace,Elemental Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.