Results 1 to 3 of 3

Thread: Firefox Glitch

  1. #1
    Join Date
    Aug 2011
    Location
    Rep Of Ireland
    Posts
    126
    Thanks
    24
    Thanked 3 Times in 1 Post

    Default Firefox Glitch

    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 ?

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    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>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. The Following User Says Thank You to djr33 For This Useful Post:

    Webiter (01-19-2012)

  4. #3
    Join Date
    Aug 2011
    Location
    Rep Of Ireland
    Posts
    126
    Thanks
    24
    Thanked 3 Times in 1 Post

    Default

    Of course... what was I thinking of!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •