This is a discussion on Local server not parsing PHP when in HTML within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hello, I've set up Apache, PHP and MySQL on my local PC. The problem I'm having is that ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello, I've set up Apache, PHP and MySQL on my local PC. The problem I'm having is that whenever PHP code is in an HTML file, the local Apache server is not parsing the PHP code. I've checked around in the Apache httpd.conf file and can't figure out what I'm doing wrong. I'd appreciate any help. |
|
|||
|
"Greg" <voyagerxv@yahoo.com> kirjoitti
viestissä:km5b41hqivepvpa00llposb42kjo7au4dn@4ax.c om... > > Hello, > > I've set up Apache, PHP and MySQL on my local PC. The problem I'm > having is that whenever PHP code is in an HTML file, the local Apache > server is not parsing the PHP code. > > I've checked around in the Apache httpd.conf file and can't figure out > what I'm doing wrong. > Just to make sure: the html files containing php, surely they are not named ..html but .php? If named .html the php parser does not recognize the file as something that should be executed, it only executes the ones named .php. |
|
|||
|
"Greg" <voyagerxv@yahoo.com> ???????/???????? ? ???????? ?????????:
news:km5b41hqivepvpa00llposb42kjo7au4dn@4ax.com... > > Hello, > > I've set up Apache, PHP and MySQL on my local PC. The problem I'm > having is that whenever PHP code is in an HTML file, the local Apache > server is not parsing the PHP code. > > I've checked around in the Apache httpd.conf file and can't figure out > what I'm doing wrong. > Try modifying your httpd.conf like this: Addtype application/x-httpd-php .php .php3 change to Addtype application/x-httpd-php .php .php3 .htm .html |
|
|||
|
> Try modifying your httpd.conf like this:
> > Addtype application/x-httpd-php .php .php3 > > change to > > Addtype application/x-httpd-php .php .php3 .htm .html > This is really a bad practice though. This will tell apache to process all html file with php preprocessor. You should use php extension (php, php3, phtml...) for file containing php code and leave .html and .htm for plain html file. It's a completely useless waste of resource to have php preprocessor to process files that contains no php code. Unless you have no plain html file, this is not a good way of doing things... and even if you don't have plain html, this is bad practice anyway... you'll never see that kind of settings in a good production server so you could face some problem if you move your sites to another server someday. Dae |
|
|||
|
I performed the steps shown below, and it works. Here's the story. I took over the site I'm working on from someone else. He/she must have been using bad practices then. The PHP code 'snippet' in question is in the index.htm as well as other html documents. It displays page footers and a navigation menu. If PHP code shouldn't be in index.htm, I assume then that navigation menus and page footers would then have to be coded as html, at least within the index.html file; and that all other files that he/she coded in which exists PHP code should be renamed as .PHP files. Right? I thank everyone for their help on this subject. Greg On Sat, 26 Mar 2005 15:06:01 -0500, "Daedalus" <daedalus@videotron.ca> wrote: >> Try modifying your httpd.conf like this: >> >> Addtype application/x-httpd-php .php .php3 >> >> change to >> >> Addtype application/x-httpd-php .php .php3 .htm .html >> > >This is really a bad practice though. This will tell apache to process all >html file with php preprocessor. You should use php extension (php, php3, >phtml...) for file containing php code and leave .html and .htm for plain >html file. It's a completely useless waste of resource to have php >preprocessor to process files that contains no php code. Unless you have no >plain html file, this is not a good way of doing things... and even if you >don't have plain html, this is bad practice anyway... you'll never see that >kind of settings in a good production server so you could face some problem >if you move your sites to another server someday. > >Dae > > |
|
|||
|
Greg wrote:
> I performed the steps shown below, and it works. > > Here's the story. I took over the site I'm working on from someone > else. He/she must have been using bad practices then. > > The PHP code 'snippet' in question is in the index.htm as well as > other html documents. It displays page footers and a navigation menu. > > If PHP code shouldn't be in index.htm, I assume then that navigation > menus and page footers would then have to be coded as html, at least > within the index.html file; and that all other files that he/she coded > in which exists PHP code should be renamed as .PHP files. Right? > Yup, PHP code should live in .php files (along with any inline HTML) for best practice. If a file is *pure* HTML, then it should be a .htm (.html) file. -- Oli |