views:

134

answers:

5

Look at this URL in Chrome and Firefox.

http://gymshuffle.com/contact.html

If FF, there's uninterpreted PHP code on the page. In Chrome there isn't.

What would cause the PHP to display in Firefox?

+6  A: 

Your http server is not configured to send .html-files through the php-interpreter. Try to rename your file from index.html to index.php. Chances are good that this will probably work - but really, please ask your server administrator for help in this configuration issue.

Regards

rbo

rubber boots
Ah. Such a stupid oversight. For some reason Chrome doesn't show the PHP in the source though.
Bill Brasky
A: 

That's interesting. If you look at the html source, you can see the php code in FF, but not in Chrome. Perhaps a MIME issue? You could also try changing the file extension to .php.

jrummell
Changing the file ext worked. Not sure if MIME is the correct answer but in the end the error was careless.
Bill Brasky
+1  A: 

Firefox is considering everything from the <?php to the /> in the first <br /> tag to be one big HTML tag. Chrome is just ignoring everything in the PHP tags. In order to make the PHP work you have to change the file extension to .php

PHP is a server-side language, so none of the processing is done by the browser.

Tom Smilack
+6  A: 

That's interesting, it looks like Chrome realizes that what's between >?php and? < isn't a browser tag, and is instead maleformed HTML, and never lets it get to the rendered HTML tree. You can see a much simpler version of the same thing here

Source code

<?php echo ('test'); ?>
test

URL:

http://alanstorm.com/testbed/chrome-php.html

If you view source with Chrome the PHP code isn't displayed. If you do it with Firefox it is.

The important thing to remember here is that your PHP code isn't being executed. Chrome downloads the page with the raw PHP code in it, sees the raw PHP code, and removes it before rendering the page.

Alan Storm
Thanks for putting up the test site so other people who see this question can refer to it. I guess Chrome is just being smarter.
Bill Brasky
I'm not sure it's the 100% smarter choice. Not seeing it in the browser makes sense, but it hides it when you view source as well, which I think is the "Wrong Thing" to do (from a developer standpoint)
Alan Storm
A: 

PHP is server-side. The browser has nothing to do with the interpretation of it.

Duddly