473,661 Members | 2,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

file extension .php or .html?

Els
If I use <? include "file.html" ; ?> in the html of my
document, do I _have_ to change the extension of that
document to .php, or would it still work and be valid if I
let it remain .html?
--
Els

Mente humana é como pára-quedas; funciona melhor aberta.
Jul 20 '05 #1
6 5459
"Els" <el*********@PL EASEtiscali.nl. invalid> wrote in message
news:bi******** **@reader1.tisc ali.nl...
If I use <? include "file.html" ; ?> in the html of my
document, do I _have_ to change the extension of that
document to .php, or would it still work and be valid if I
let it remain .html?


Apples and oranges. The HTML is valid if the HTML is valid. It's not what
file name your PHP script has. PHP is _server side_ and HTML is the
presentation to the browser _after_ all the server side stuff has happened.
There's not even any reason to ever have a file extension on web content at
all (except to make the files more friendly to applications that pay
attention to the file extension--mostly Win32 stuff). In fact, it's common
practice to create CMS-type scripts with no file extension so the web server
can reference the resource through a friendlier directory-like URI.

By adding that one line of PHP code, you have, in fact, created a
fully-functioning PHP script. This file now requires the HTTP host to
filter it through the PHP parser. On many HTTP hosts, you can set it to
only filter *.php files, or you can set it to filter any combination of
files with a given extension. If your page is working on your server and is
being processed by the PHP parser, it's fine to leave it with the .html
extension. If you ever run into a server that does not run all *.html files
through the parser, your page will not operate correctly until you do one of
two things:

1. Change the extension to "php" or...
2. Change the server's configuration. In Apache, this is as simple as
adding an .htaccess file with one line of configuration (asking to pass
*.html files through the parser). Of course, if you're not in control of
the host, this configuration directive may or may not be allowed to be
controlled in your local web directory.

If this is the extent of your PHP code, I would probably just stick to the
"html" extension. If you get really fancy, it might be more appropriate to
label the thing with a "php" extension so someone else can maintain your
site (I know, it probably won't fall into someone else's hands anyway)
without too much headache.

HTH,
Zac
Jul 20 '05 #2
Els
Els wrote:
Zac Hester wrote:
2. Change the server's configuration. In Apache, this is as simple as
adding an .htaccess file with one line of configuration (asking to pass
*.html files through the parser). Of course, if you're not in control of
the host, this configuration directive may or may not be allowed to be
controlled in your local web directory.

If this is the extent of your PHP code, I would probably just stick to
the "html" extension. If you get really fancy, it might be more appropriate to label the thing with a "php" extension so someone else can maintain your
site (I know, it probably won't fall into someone else's hands anyway)
without too much headache.

HTH,


It did. Thanks for this very complete answer, appreciate it :-)


...and now comes the next question ;-)
I now know, that my server doesn't parse html files as php.
Can you tell me what that one line of configuration in an
..htaccess file would have to be? To what do I 'add' an
..htaccess file? To every folder of the website, or only to
the main (first) one? Or can you give me a link to a clear
instruction somewhere? I googled, but all I could find was
someone saying: 'it has been discussed before, so you should
be able to find it in the archives', but I couldn't find
anything...

Thanks,

--
Els

Mente humana é como pára-quedas; funciona melhor aberta.

Jul 20 '05 #3
Els
Els wrote:
Els wrote:
Zac Hester wrote:
2. Change the server's configuration. In Apache, this is as simple as
adding an .htaccess file with one line of configuration (asking to pass
*.html files through the parser). Of course, if you're not in
control of
the host, this configuration directive may or may not be allowed to be
controlled in your local web directory.

If this is the extent of your PHP code, I would probably just stick
to the "html" extension. If you get really fancy, it might be more
appropriate to label the thing with a "php" extension so someone else
can maintain your
site (I know, it probably won't fall into someone else's hands anyway)
without too much headache.

HTH,

It did. Thanks for this very complete answer, appreciate it :-)

..and now comes the next question ;-)
I now know, that my server doesn't parse html files as php.
Can you tell me what that one line of configuration in an .htaccess file
would have to be? To what do I 'add' an .htaccess file? To every folder
of the website, or only to the main (first) one? Or can you give me a
link to a clear instruction somewhere? I googled, but all I could find
was someone saying: 'it has been discussed before, so you should be able
to find it in the archives', but I couldn't find anything...


I did find something: ForceType application/x-httpd-php
I uploaded it, and my .html files are now parsed as .php,
but now my images won't display, because of a parse error.

Anyone know what I should type instead of ForceType
application/x-httpd-php?

Thanks,

--
Els

Mente humana é como pára-quedas; funciona melhor aberta.

Jul 20 '05 #4
Els <el*********@PL EASEtiscali.nl. invalid>:
Els wrote:
Els wrote:
Zac Hester wrote:

2. Change the server's configuration. In Apache, this is as simple as
adding an .htaccess file with one line of configuration (asking to pass
*.html files through the parser). Of course, if you're not in
control of
the host, this configuration directive may or may not be allowed to be
controlled in your local web directory.

If this is the extent of your PHP code, I would probably just stick
to the "html" extension. If you get really fancy, it might be more
appropriate to label the thing with a "php" extension so someone else
can maintain your
site (I know, it probably won't fall into someone else's hands anyway)
without too much headache.

HTH,
It did. Thanks for this very complete answer, appreciate it :-)

..and now comes the next question ;-)
I now know, that my server doesn't parse html files as php.
Can you tell me what that one line of configuration in an .htaccess file
would have to be? To what do I 'add' an .htaccess file? To every folder
of the website, or only to the main (first) one? Or can you give me a
link to a clear instruction somewhere? I googled, but all I could find
was someone saying: 'it has been discussed before, so you should be able
to find it in the archives', but I couldn't find anything...


I did find something: ForceType application/x-httpd-php
I uploaded it, and my .html files are now parsed as .php,
but now my images won't display, because of a parse error.

Anyone know what I should type instead of ForceType
application/x-httpd-php?

I have to use the *.php extension if I include any php in the source.

..htaccess ? n.i.w.server-side answers, mostly in Dutch :-)
I can't find yr .htaccess solution very quickly :-(
John OO
--

<http://webcel.nl/>
<http://www.webcel.nl/bayshop/shop/bayshop.html>

"Time is what prevents everything from happening at once"
- John Archibald Wheeler -
Jul 20 '05 #5
Els wrote:

This is all blatantly off-topic. Would someone else please set an
appropriate followup-to?
Can you tell me what that one line of configuration in an .htaccess
file would have to be?
There's a hint in the PHP 'INSTALL' file:

And finally you need to tell Apache which file extension should
trigger PHP. You do this by creating a special mime type and
associating it with an extension. We suggest using:

AddType application/x-httpd-php .php

Perhaps you might try

AddType application/x-httpd-php .html
To what do I 'add' an .htaccess file? To every folder of the website,
or only to the main (first) one?
Under apache, .htaccess files affect the directory they are located in
as well as all subdirectories, barring changes in the subdirectory's
own htaccess file.
Or can you give me a link to a clear instruction somewhere?


The best instructions you're likely to find are in the manual for your
specific web server. .htaccess is generally an apache thing, in which
case you want <http://httpd.apache.or g/docs-project/>.
Jul 20 '05 #6
Els
Owen Jacobson wrote:
Els wrote:

This is all blatantly off-topic.
It _was_.
Would someone else please set an
appropriate followup-to?
There was no follow up, I've redirected the question to
another newsgroup, as you can see in my message of 31-8-2003
23:27 :-)
Can you tell me what that one line of configuration in an .htaccess
file would have to be?


There's a hint in the PHP 'INSTALL' file:


I have not 'installed' PHP on my computer, I'm dealing with
the server where my site is being hosted.
And finally you need to tell Apache which file extension should
trigger PHP. You do this by creating a special mime type and
associating it with an extension. We suggest using:

AddType application/x-httpd-php .php

Perhaps you might try

AddType application/x-httpd-php .html


I did already (and it works as I wanted it to), thanks to
the answers I got in nl.internet.www w.server-side and
comp.lang.php :-)
To what do I 'add' an .htaccess file? To every folder of the website,
or only to the main (first) one?


Under apache, .htaccess files affect the directory they are located in
as well as all subdirectories, barring changes in the subdirectory's
own htaccess file.


So I've heard ;-)
Or can you give me a link to a clear instruction somewhere?


The best instructions you're likely to find are in the manual for your
specific web server. .htaccess is generally an apache thing, in which
case you want <http://httpd.apache.or g/docs-project/>.


Thanks,

--
Els

Mente humana é como pára-quedas; funciona melhor aberta.

Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3334
by: Terence | last post by:
A curious observation: I have my apache web server configured for the PHP apache module to parse files ending in the .php extension. nothing unusual about that, but I also noticed that if I leave the file extension off completely, not only does apache map it to the corresponding php file, but it allows the php module to parse it accordingly.
2
1491
by: JeffFinnan | last post by:
Is there a way Netscape 4.x can be forced to select a particular file extension other than the default .html? =============================== <form name=form1> <input type=file name="fileN"> <input type=button onClick="setContent(1)" value="Open File"> </form>
15
2222
by: alamsetti | last post by:
I have recently installed php, apache on windows xp. I have wrote a simple test file -- test.php <?php echo "hello world" ?>
3
6489
by: David | last post by:
Should you be able to map a any file extension to the ASP.NET dll and have it execute ASP.NET script, just like an .aspx page, when it is requested by a browser. If not, why bother giving us the ability to create application mappings. I have an .aspx page that calls an SAP function which returns an actual PDF to my calling .aspx. My .aspx then returns that PDF result to the browser. When a browser requests that .aspx page, if I try...
1
1344
by: Joe | last post by:
Hi, I haven’t mastered the asp.net yet to be able to use asp.net 2.0 master pages. So I am planning to create pages with .aspx extension and once I am confident, I will rewrite them using master pages. The purpose of this exercise is that I will be able to keep the filenames same. All of these pages have a horizontal navigation menu. For the time being, I am separating the simple html code of this horizontal menu into a separate...
19
3827
by: Badr.ALmuzini | last post by:
hi,there how can i make php file extension hidden in the URL somthing like this (http://mail.google.com/mail/?view) Regard....
6
4896
by: VishalK | last post by:
Friends.. I have a HTML file. Using HTML Code, I want to change its file extension from .html to .mht. eg : TestFile.html to be converted to TestFile.mht Anybody has any idea about this ? Please let me know. Thanks in advance. Regards, Vishal
38
5059
by: ted | last post by:
I have an old link that was widely distributed. I would now like to put a link on that old page that will go to a new page without displaying anything.
29
2141
by: lenbell | last post by:
It's old stupid and lazy here again I have been wanting to keep using my WYSIWYG (What You See Is What You Get - for my fellow stupids) html editor. But I was told that you HAD to rename your files to .PHP so they would be parsed correctly. Oh contraire if you are hosted by Apache and have some access to the .htaccess file mechanism In my case through the "cPanel" and then "Apache Handlers"
0
8343
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8855
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7364
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1986
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.