Thankyou! Yes that works.
Excuse my ignorance - but is the .php extension likely to affect anything else ie customers/users won't have any problems? I'll have to change all my pages to .php.
Thankyou! Yes that works.
Excuse my ignorance - but is the .php extension likely to affect anything else ie customers/users won't have any problems? I'll have to change all my pages to .php.
There should be no problem renaming pages to .php, except that pages (if any) that were bookmarked as .html will no longer be there. You could leave a blank .html page behind for each though with a meta refresh tag on it that redirects to the PHP version. Or use .htaccess to redirect all calls to .html to their ,php versions.
BTW, the 'top' page (the including page, like aptenia_test.php) needs to have the .php extension, but the included page - like linklist.php does not.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Absolutely correct-- any pages that include activeBTW, the 'top' page (the including page, like aptenia_test.php) needs to have the .php extension, but the included page - like linklist.php does not.<?php /*PHP*/ ?>must have the .php extension.
On a technical note, I believe that adding the .php extension to the included page (the content) versus .htm will determine whether <?php ?> code blocks are parsed in the including page (the holder page) when that file's code is included. I'm not actually positive exactly how that works. But as a general rule: if you need PHP code from the second page to work in the first (in this case you do not), then use .php on both pages. If not, you can use .htm on the included page but always need .php for the including page. In general, though, I suggest using either .php or .htm consistently for the same content since that's easier to keep track of and allows for future use of any PHP code you might want, without the bookmarking problem John mentioned.
The .php extension is irrelevant. PHP code, by fundamental design, generates HTML code which is in every way identical to ".htm" HTML code. Then the proper headers are sent by your server so that the browser knows it's an HTML-type file (even though it's .php). In fact, you can rename any .htm file you'd like to .php and you won't see any changes at all.*
The only "difference" is the extension itself; all visitors will be able to view the page perfectly, but if you like the look and feel of the .htm ending, you won't get that with PHP. Here are three solutions, probably all overkill-- PHP is very common on the web-- look at the URL for the forum and you'll see .php there.
1) Tell your server to parse .htm files as .php. This could potentially slow the server very slightly (probably not noticeably), and the result would be that any PHP code on any .htm page would be parsed like that. As a security warning, be sure that no one without admin privelages (eg, FTP access) can upload a .htm file. Just like a PHP file then, it could be used to hack your site. (This isn't a security issue unless you allow public uploading.) If you want to do that, you can search for it based on your server's configuration (or let us know the details). You would need configuration access to change the settings.
2. Use .htaccess mod_rewrite (basically a way to "lie" to the visitor to use a fake URL to display a different page to mask all of the real .php files with .htm URLs. This puts very little burden on the server and it's not too hard to do, although for a beginner .htaccess is very difficult (in my experience). If you can find some code that's ready to go, though, it could be easy. Search around if you'd like.
3. My personal suggestion is to NOT use any file URLs. Instead, create index.php OR index.htm files and use directory names.
So your current site might have: mysite.com/mypage.htm. Instead, create an index.htm or index.php within the directory mysite.com/mypage/ and all of your pages will be very clean like that. It's a little bit of manual work (setting up all of those folders and storing all of the HTML files in different places), but the result is pretty URLs, and you also have a great added bonus that by referring to the URL of the directory rather than a file, it can refer to BOTH html and php, so bookmarks will always be valid for any type of file as the index page.
I hope that answers your question. Let me know if anything was unclear.
(*The only technical detail here is that because it's .php your server will check it for PHP code and try to run any PHP in it, so it might create a probably unnoticeable delay in serving the page-- a couple of milliseconds maybe. Unless you have an incredibly high traffic site, there's nothing to worry about. Either way, changing regular HTML files to PHP is certainly not required though.)
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
also, for using PHP without php file extensions:Originally Posted by php.net/manual/en/function.include.php
Code:#in your htaccess file # (ALWAYS keep your existing htaccess file - # add to it or comment lines out - NEVER overwrite it!) AddHandler application/x-httpd-php .php .htm .html # now all files with .php, .htm, OR .html will be parsed by php :)
Bookmarks