File extensions

I've checked tutorials but could not find my answer. I have an html page
which has one line of php in it slipped in between all my regular html
stuff. My server has told me that for it to work, I have to have the html
file end in .php. So, I renamed test1.html to test1.php and it worked. Is
that the case everywhere or could it just be my server? This is the first
time I have gotten output from any php coding...I was amazed it worked.
Yes, newbie to php. :)

Any comments welcome.
Thad
thad [ Di, 27 Februar 2007 00:34 ] [ ID #1640676 ]

Re: File extensions

On Mon, 26 Feb 2007 16:34:47 -0700, "Thad" <tsobota [at] cox.net> wrote:

>file end in .php. So, I renamed test1.html to test1.php and it worked. Is
>that the case everywhere or could it just be my server?

No, it depends on the server set-up. The server can be configured to
run PHP within .html files, or mod_rewrite could be used, but it is
non-standard. Unless you have a particular reason why you can't use
..php file extensions, it should not be a problem.

--
------------------------------------------------------------ ------
- Stuart Millington ALL HTML e-mail rejected -
- mailto:phupp [at] dsv1.co.uk http://www.z-add.co.uk/ -
Stuart Millington [ Di, 27 Februar 2007 00:44 ] [ ID #1640677 ]

Re: File extensions

"Stuart Millington" <news [at] dsv1.co.uk> wrote in message
news:l1s6u29qi1ufpkcrpn9s2369r8smgvu0nl [at] 4ax.com...
> On Mon, 26 Feb 2007 16:34:47 -0700, "Thad" <tsobota [at] cox.net> wrote:
>
>>file end in .php. So, I renamed test1.html to test1.php and it worked.
>>Is
>>that the case everywhere or could it just be my server?
>
> No, it depends on the server set-up. The server can be configured to
> run PHP within .html files, or mod_rewrite could be used, but it is
> non-standard. Unless you have a particular reason why you can't use
> .php file extensions, it should not be a problem.

So it looks like my server does mod_rewrite. It's just this is the first
time I had run into this.

Thanks so much Stuart.
Much appreciated,
Thad
thad [ Di, 27 Februar 2007 00:50 ] [ ID #1640678 ]

Re: File extensions

On 26 Feb, 23:50, "Thad" <tsob... [at] cox.net> wrote:
> "Stuart Millington" <n... [at] dsv1.co.uk> wrote in message
>
> news:l1s6u29qi1ufpkcrpn9s2369r8smgvu0nl [at] 4ax.com...
>
> > On Mon, 26 Feb 2007 16:34:47 -0700, "Thad" <tsob... [at] cox.net> wrote:
>
> >>file end in .php. So, I renamed test1.html to test1.php and it worked.
> >>Is
> >>that the case everywhere or could it just be my server?
>
> > No, it depends on the server set-up. The server can be configured to
> > run PHP within .html files, or mod_rewrite could be used, but it is
> > non-standard. Unless you have a particular reason why you can't use
> > .php file extensions, it should not be a problem.
>
> So it looks like my server does mod_rewrite. It's just this is the first
> time I had run into this.
>
> Thanks so much Stuart.
> Much appreciated,
> Thad

your server is set up to execute the php inside the files if they end
in .php which is normal. Stuart meant that if you have control over
the server you could change this to say only .pjio files or
a .phtml, .php and .php5 all at once etc.. whatever you choose,
or if you have access to the way apache works, (you probably do
via .htaccess files) you could rewrite (that is redirect) the URL that
your visitor has asked for, say script.html to script.php, but not let
the user know you have done it (a so called internal rewrite)

RewriteRule script.html script.php [L]

this would meant that while the file extension could remain .html, the
server is actually "forwarding" on the request to a file that ended
in .php which would be the script that would actually be doing the
work, whereas script.html would just be a fake, even a non existent
file that your user would see.
This is sometimes used in conjunction with other methods to hide the
server technology behind the dynamic pages, making it harder to
profile before an attack (since you could be using .NET jps and other
technologies apart from php)

Hope that clears it up a bit.
shimmyshack [ Di, 27 Februar 2007 01:13 ] [ ID #1641821 ]

Re: File extensions

shimmyshack wrote:

> your server is set up to execute the php inside the files if they end
> in .php which is normal. Stuart meant that if you have control over
> the server you could change this to say only .pjio files or
> a .phtml, .php and .php5 all at once etc.. whatever you choose

There is those who uses

AddType application/x-httpd-php .html

Which will cause the server to work extra as it will parse all html files, of
which most usually don't have any php at all.

--

//Aho
Shion [ Di, 27 Februar 2007 01:55 ] [ ID #1641824 ]

Re: File extensions

On Tue, 27 Feb 2007 01:55:03 +0100, "J.O. Aho" <user [at] example.net>
wrote:

>There is those who uses
>
> AddType application/x-httpd-php .html
>
>Which will cause the server to work extra as it will parse all html files, of
>which most usually don't have any php at all.

And it can mess up caching - as html files are usually static, whereas
php files have "on the fly generation times" - unless one is careful.
Can be useful, but not a good thing to do without looking at the
server load, as you mention, and bandwidth consequences.

--
------------------------------------------------------------ ------
- Stuart Millington ALL HTML e-mail rejected -
- mailto:phupp [at] dsv1.co.uk http://www.z-add.co.uk/ -
Stuart Millington [ Di, 27 Februar 2007 02:18 ] [ ID #1641825 ]

Re: File extensions

On Mon, 26 Feb 2007 16:50:40 -0700, "Thad" <tsobota [at] cox.net> wrote:
>"Stuart Millington" <news [at] dsv1.co.uk> wrote in message
>news:l1s6u29qi1ufpkcrpn9s2369r8smgvu0nl [at] 4ax.com...

>> No, it depends on the server set-up. The server can be configured to
>> run PHP within .html files, or mod_rewrite could be used, but it is
>> non-standard. Unless you have a particular reason why you can't use
>> .php file extensions, it should not be a problem.
>
>So it looks like my server does mod_rewrite.

Er, no, sorry. Well it may do mod_rewrite for other things, but that's
not connected in this case and "shimmyshack" explained it far better
than me ;-)

--
------------------------------------------------------------ ------
- Stuart Millington ALL HTML e-mail rejected -
- mailto:phupp [at] dsv1.co.uk http://www.z-add.co.uk/ -
Stuart Millington [ Di, 27 Februar 2007 02:21 ] [ ID #1641826 ]

Re: File extensions

J.O. Aho wrote:
> shimmyshack wrote:
>
>> your server is set up to execute the php inside the files if they end
>> in .php which is normal. Stuart meant that if you have control over
>> the server you could change this to say only .pjio files or
>> a .phtml, .php and .php5 all at once etc.. whatever you choose
>
> There is those who uses
>
> AddType application/x-httpd-php .html
>
> Which will cause the server to work extra as it will parse all html
> files, of which most usually don't have any php at all.
>
#allow only .php and .htm to be parsed for php code
AddType application/x-httpd-php .php .htm


#allow .php, .htm, and .mycustomextension to be parsed for php code
AddType application/x-httpd-php .php .htm .mycustomextension

All other extensions (unless dealt with appropriately) will be served as
static HTML, eg: .html, .shtml, .mystatichtml, etc.

Norm
Norman Peelman [ Di, 27 Februar 2007 03:49 ] [ ID #1641827 ]

Re: File extensions

> your server is set up to execute the php inside the files if they end
> in .php which is normal.
Now this I can understand. Creates a hastle though since I will not be able
to validate my html pages if I have to have php extension. I'm working on a
workaround for the validation. I'll just rename the file for validation
purposes then rename it to php to load on server.


> Hope that clears it up a bit.
>

Yes it did. I will just have to deal with the changes.

Thanks a bunch!
Thad
thad [ Di, 27 Februar 2007 04:17 ] [ ID #1641828 ]

Re: File extensions

Thank you all for responding. Now I have a better grasp on things.

Thad
thad [ Di, 27 Februar 2007 04:18 ] [ ID #1641829 ]

Re: File extensions

On 27 Feb, 03:18, "Thad" <tsob... [at] cox.net> wrote:
> Thank you all for responding. Now I have a better grasp on things.
>
> Thad

with regards validation, provided your scripts have been executed they
will validate, so I assume you are using tidy or something like that,
you have 2 options, either install tidy within firefox so that each
new page of php you write when executed will show up in your browser
and the resulting html will be automatically validated, the firefox
addon can be found here:
https://addons.mozilla.org/firefox/249/

or use the online validator
http://validator.w3.org/
and instead of uploading a block of html, simple point it at your php
page on the server. and validate by URL, as it requests your page, it
will be executed and the resultant html served to it for validation
automatically.
shimmyshack [ Di, 27 Februar 2007 04:36 ] [ ID #1641830 ]

Re: File extensions

"shimmyshack" <matt.farey [at] gmail.com> wrote in message
news:1172547416.500599.46320 [at] m58g2000cwm.googlegroups.com...
> On 27 Feb, 03:18, "Thad" <tsob... [at] cox.net> wrote:
>> Thank you all for responding. Now I have a better grasp on things.
>>
>> Thad
>
> with regards validation, provided your scripts have been executed they
> will validate, so I assume you are using tidy or something like that,
> you have 2 options, either install tidy within firefox so that each
> new page of php you write when executed will show up in your browser
> and the resulting html will be automatically validated, the firefox
> addon can be found here:
> https://addons.mozilla.org/firefox/249/
>
> or use the online validator
> http://validator.w3.org/
> and instead of uploading a block of html, simple point it at your php
> page on the server. and validate by URL, as it requests your page, it
> will be executed and the resultant html served to it for validation
> automatically.
>
I have been validating on the w3c site. I love it. I've been using the
file upload part which does not validate php, but since you moved my nose
over a bit, :) , I can see where to validate by url. lol...I must be blind.

Thanks again!!!!
Thad
thad [ Di, 27 Februar 2007 04:48 ] [ ID #1641831 ]

Re: File extensions

..oO(Thad)

>I have been validating on the w3c site. I love it. I've been using the
>file upload part which does not validate php, but since you moved my nose
>over a bit, :) , I can see where to validate by url. lol...I must be blind.

Yet another option: In Opera browser you just have to press ctrl-alt-v
to have him sending the currently visible page's source code to the W3
validator.

Micha
Michael Fesser [ Di, 27 Februar 2007 17:51 ] [ ID #1641845 ]
PHP » alt.php » File extensions

Vorheriges Thema: Can I get the form name from $_POST?
Nächstes Thema: Free web hosting that allows PHP XSLT