Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is PHP not interpreted in FF but is interpreted in Chrome on my website?

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?

like image 212
Bill Brasky Avatar asked Aug 18 '10 17:08

Bill Brasky


2 Answers

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.

Update: Saw an upvote on this in 2015 -- and it looks like Chrome now does display the mentioned code.

like image 60
Alan Storm Avatar answered Sep 20 '22 02:09

Alan Storm


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

like image 32
rubber boots Avatar answered Sep 20 '22 02:09

rubber boots