php doesn't work in html files

This is a discussion on php doesn't work in html files within the PHP General forums, part of the PHP Programming Forums category; Hi there all, I use Apache version 1.3 and WIndows 2000. The site is not global but only local ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-11-2004
Nico Berg
 
Posts: n/a
Default php doesn't work in html files

Hi there all,

I use Apache version 1.3 and WIndows 2000. The site is not global but only
local so I use the url http://localhost/index.html

This index.html look's like this:

<html>
<body>
This is a line
</body>
</html>

<?
echo "this is the second line";
?>

Output is: This is a line

So the php part is not done at all. Is that right? I always believed php
should work in html?

Nico
Reply With Quote
  #2 (permalink)  
Old 01-11-2004
Stuart
 
Posts: n/a
Default Re: [PHP] php doesn't work in html files

Nico Berg wrote:
> Hi there all,
> This index.html look's like this:
>
> <html>
> <body>
> This is a line
> </body>
> </html>
>
> <?
> echo "this is the second line";
> ?>
>
> Output is: This is a line
>
> So the php part is not done at all. Is that right? I always believed php
> should work in html?


Assuming you have the web server set up according to PHP's installation
docs, you either need to rename index.html to index.php or tell the web
server to run .html files through PHP (refer to the PHP manual for
details on how to do this).

--
Stuart
Reply With Quote
  #3 (permalink)  
Old 01-11-2004
Jason Wong
 
Posts: n/a
Default Re: [PHP] php doesn't work in html files

On Sunday 11 January 2004 21:04, Nico Berg wrote:

> I use Apache version 1.3 and WIndows 2000. The site is not global but only
> local so I use the url http://localhost/index.html
>
> This index.html look's like this:


[snip]

> So the php part is not done at all. Is that right? I always believed php
> should work in html?


By default the webserver only treats files with the .php extension (and a few
others, see your webserver config) as PHP files.

If you want it to process .html files as PHP then look for the following line
(or similar) in httpd.conf:

AddType application/x-httpd-php .php4 .php3 .phtml .php .inc

and add .html to the end of it, then restart Apache.

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
"I got everybody to pay up front...then I blew up their planet."
"Now why didn't I think of that?"
-- Post Bros. Comics
*/
Reply With Quote
  #4 (permalink)  
Old 01-11-2004
Madhd
 
Posts: n/a
Default Re: [PHP] php doesn't work in html files

----- Original Message -----
From: "Nico Berg"
To: "'PHP General'"
Sent: Sunday, January 11, 2004 2:04 PM
Subject: [php] php doesn't work in html files


> Hi there all,
>
> I use Apache version 1.3 and WIndows 2000. The site is not global but only
> local so I use the url http://localhost/index.html
>
> This index.html look's like this:
>
> <html>
> <body>
> This is a line
> </body>
> </html>
>
> <?
> echo "this is the second line";
> ?>
>
> Output is: This is a line
>
> So the php part is not done at all. Is that right? I always believed php
> should work in html?


Try to rename the .html file in .php (index.html -> index.php) and test it.
You can reconfigure apache to pass all .html files to php compiler but i
don't recommend it because it reduce drastically the performance.

Heber
Reply With Quote
  #5 (permalink)  
Old 01-11-2004
Chris Shiflett
 
Posts: n/a
Default Re: [PHP] php doesn't work in html files

--- Nico Berg <nberg@gandalf.xs4all.nl> wrote:
> I use Apache version 1.3 and WIndows 2000.


[snip]

> <?
> echo "this is the second line";
> ?>
>
> Output is: This is a line
>
> So the php part is not done at all.


Do you have PHP installed?

Chris

=====
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
Coming mid-2004
HTTP Developer's Handbook
http://httphandbook.org/
Reply With Quote
  #6 (permalink)  
Old 01-11-2004
Shawn McKenzie
 
Posts: n/a
Default Re: php doesn't work in html files

Wow, my posts on the average get 0 or 1 (not helpful reply)... This one
gets 4 identical replies!!!

-Shawn :)

"Nico Berg" <nberg@gandalf.xs4all.nl> wrote in message
news:IEEBJCNANAAAMKCGAEKLEEMBCHAA.nberg@gandalf.xs 4all.nl...
> Hi there all,
>
> I use Apache version 1.3 and WIndows 2000. The site is not global but only
> local so I use the url http://localhost/index.html
>
> This index.html look's like this:
>
> <html>
> <body>
> This is a line
> </body>
> </html>
>
> <?
> echo "this is the second line";
> ?>
>
> Output is: This is a line
>
> So the php part is not done at all. Is that right? I always believed php
> should work in html?
>
> Nico

Reply With Quote
  #7 (permalink)  
Old 01-12-2004
Chris Shiflett
 
Posts: n/a
Default Re: [PHP] Re: php doesn't work in html files

--- Shawn McKenzie <nospam@mckenzies.net> wrote:
> Wow, my posts on the average get 0 or 1 (not helpful reply)...
> This one gets 4 identical replies!!!


Because the replies to the question that you quoted were all different,
your comment makes no sense (I'm not sure that it would make sense
anyway).

If you are trying to make an important point, please rephrase your
comment. Otherwise, please refrain from making off-topic comments.

Thanks.

Chris

=====
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
Coming mid-2004
HTTP Developer's Handbook
http://httphandbook.org/
Reply With Quote
  #8 (permalink)  
Old 01-12-2004
Nico Berg
 
Posts: n/a
Default RE: [PHP] php doesn't work in html files

Hi,

It works. I decided to add .html to the list of extensions that will be
opend by php if asked for in apache. I understand here that it will take
more time before html files are processed? True?

Thanks all, Nico Berg

> -----Oorspronkelijk bericht-----
> Van: Nico Berg [mailto:nberg@gandalf.xs4all.nl]
> Verzonden: zondag 11 januari 2004 14:05
> Aan: 'PHP General'
> Onderwerp: [php] php doesn't work in html files
>
>
> Hi there all,
>
> I use Apache version 1.3 and WIndows 2000. The site is not global but only
> local so I use the url http://localhost/index.html
>
> This index.html look's like this:
>
> <html>
> <body>
> This is a line
> </body>
> </html>
>
> <?
> echo "this is the second line";
> ?>
>
> Output is: This is a line
>
> So the php part is not done at all. Is that right? I always believed php
> should work in html?
>
> Nico
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:43 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0