I believe that it is not actually working in any browser, but other browsers other than Chrome should be downloading the file instead of displaying or should be interpreting as text/html
, which ignores php tags making you think they are html tags, Chrome must be interpreting as plain/text
.
How I answered here:
Understand that the Apache, Ngnix and other equivalent servers do not use standard extensions, in fact it is you who customize, you can even invent your own extension if you wish, for example by editing the httpd.conf
in the apache:
AddType application/x-httpd-php .php
AddType application/x-httpd-php .miguel
Ready, it will be possible to use .miguel
as an extension to run php files. You can still add index files with custom extensions for example:
<IfModule dir_module>
DirectoryIndex index.php index.pl index.html index.htm index.miguel
</IfModule>
So why .phtml
and .php
are custom things anyway and if you want to add do this:
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
And that:
<IfModule dir_module>
DirectoryIndex index.php index.pl index.html index.htm index.phtml
</IfModule>
Note: But note that not all accommodations will allow you to customize the extensions and the best thing is to stay in the most common one is to use .php
for everything, or maybe a mod_rewrite
and not using extensions
You are using zend framework?
– rray
You are not using a framework.
– Miguel Batista
Give more details of what you are trying to do, the way it is are many possibilities.
– Bacco
Why are you wearing
phtml
?– BrTkCa
Using Apache? Using any template preprocessing library? Using Zend? Why are you using PHTML?
– Wallace Maxters
When we took the project the pages were already with this extension phtml. I don’t know why they used.
– Miguel Batista
Maybe this will help answer the question What are . phtml files and when I should use them?
– Wallace Maxters
@Miguelbast using Apache? You can add a condition for them to be interpreted as PHP.
– Wallace Maxters
The strange thing is that he said that in Chrome does not work, but in others work.
– Wallace Maxters
this is strange because it already has the apache configuration to interpret the extension and the problem only occurs in Chrome. Vixi, Jesus!
– Miguel Batista
Possible duplicate of Migrate from PHP 5.2.9 to PHP 5.6.8
– Guilherme Nascimento
It may sound dumb, but... You’re actually accessing the web server URL, not a file://, right?
– bfavaretto
Thanks @bfavaretto, the url was correct. The problem was solved thanks.
– Miguel Batista
Was the answer below resolved? If not, could you put your own answer to help others with the same problem? Thank you!
– bfavaretto
The answer lowers not solved.
– Miguel Batista