I use Firefox to Run scripts that I would be working on in Notepad++. It has always worked fine but I must have broken something!
When I now Run > Launch in Firefox a script a popup box presents as the attached image. What might be the fix for this ?
In short, PHP is a language of server instructions (a server-side language) and HTML is a language of browser instructions (a client-side language), so you can't skip the server with PHP. So this is actually not a bug.
Firefox doesn't know what to do with a PHP file. A PHP file is not HTML. A PHP file is PHP code that must be processed by a server then will become HTML.* Additionally, when the PHP page (now containing only HTML, no more PHP code) is finally sent to the browser, it is sent with headers telling the browser that the file is HTML format.
Unfortunately, you don't have headers or any sort of guessing when you're using the file locally. The file extension alone (which is .php in this case) determines what the browser will do with it. By the way, if a .php file is corrupt or isn't sent with the right headers, you'll also get this, even on a live sites. I've seen that on many broken PHP websites. In most cases, the server sends the HTML header automatically so you don't even know that's happening, but if something does go wrong, that is the expected result-- unknown format.
So, this is not a bug in Firefox because it is a browser, not a server.
You have two options:
1. Rename the file .htm(l). This is fine if you don't have any PHP code (or don't mind a few items being broken), and you don't mind renaming all of your files (then renaming them again when you upload them to your server).
2. Install a local server like LAMP/WAMP on your computer to run these test files. You'll need to access them through this server, with
localhost:// rather than
file://, but this will work and it will also work with PHP (assuming you have PHP available on that server-- many/most packages do).
Or of course you could always use a real server and upload by FTP, etc.
Or you could see if there is a way to change the default behavior of firefox to assume that ".php" means HTML format, but that won't solve anything about the PHP code in it, if there is any.
(*I realize this is contradictory to what you have probably learned, that "PHP is HTML", and that's true, but only after it is processed. That's even the case if you have no PHP code at all and just name the file .php-- it becomes "real" HTML after it is run through the PHP parser, even if that parser does nothing except add the headers.)
Daniel - Freelance Web Design | <?php?> | <html>| Deutsch | italiano | espa˝ol | portuguŕs | catalÓ | un peu de franšais | Ninasoma Kiswahili | 日本語の学生でした。| درست العربية
The Following User Says Thank You to djr33 For This Useful Post:
Of course... what was I thinking of!
Tags for this Thread