Re: Basic question (?php not working in html)
| From: | Michael Kimsal | Date: | Thu, 10 Aug 2000 15:53:34 +0000 |
| Subject: | Re: Basic question (?php not working in html) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-11166@lists.php.net to get a copy of this message | ||
What was missed wasn't there - it IS a FAQ in the technical
sense, in that it gets asked quite a lot - 'how can my html pages
parse PHP'.
The short answer, which seems intuitive, but might not be, is
to duplicate the line in the httpd.conf file with the .php
and make it read .html. If you look at what that line is doing...
AddHandler application/x-httpd-php .php
it's saying 'any file ending in .php, treat is as a
httpd-php application' (poor translation, but that's
the idea).
Adding ANOTHER line below that like
AddHandler application/x-httpd-php .html
would make the server treat all .html files as PHP applications.
You could carry this on and say
AddHandler application/x-httpd-php .htm
AddHandler application/x-httpd-php .asp
AddHandler application/x-httpd-php .phtml
AddHandler application/x-httpd-php .cfml
AddHandler application/x-httpd-php .ws
etc. Applying a bit of common sense (or apparently common sense)
to the problem MIGHT have yielded the solution. As you're
poking around in the web server's conf file, one *assumes* you
have at least some knowledge of what the directives are. This
is probably a bad assumption to make for people (makes an
ass out of u and me...), but it is one which is still generally made.
The REAL answer to this question should be another question -
are you SURE you want EVERY .html file to be parsed as PHP?
It adds overhead to EVERY .html file request (although
not as much in PHP4 as in 3?) which slows everything down.
It might be handy to give the illusion that someone is looking
at 'straight' html files when in fact they're dynamic, but beyond
that, is there much point? Why not just have the .php files
be parsed and leave it at that?
<html>HELLO <?echo $name;?></html>
is a valid PHP file.
There's nothing to stop you from putting HTML into the PHP
file Ira. That's what it's there for. I would give a lecture here
about using template systems instead, but that's for another post.
Ira Mica wrote:
> At 09:36 AM 8/10/00 -0600, you wrote:
> >Does anyone else on the list think that it's high time this question &
> >answer got moved to the VERY FRONT PAGE of www.php.net? (Exaggeration,
> >but...) Because it seems like 45% of the messages on this list related to
> >this exact question & answer...
> >
> >Or maybe it could be made more prominent in the FAQ page, since Ira claims
> >to have searched the FAQ but found nothing (?!?!!)
>
> I claimed that the info in the faq didn't help. There is a QA about
> getting php to work with apache and I did follow it.
> I did say that php works if I go to a .php file. I just can't get
> the php stuff to work when embeded in html.
>
> If you think I missed something from the FAQ, let me know.
>
> Rgds
>
> __________________________________________________
>
> Do You Yahoo!?
>
> Talk to your friends online with Yahoo! Messenger.
>
> http://im.yahoo.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
--
==========================
Michael Kimsal
http://www.tapinternet.com
734-480-9961