|
|
|
|
Thread title: Page titles when using php |
|
|
|
|
|
Thread tools
Search this thread
Display Modes
|
|
05-10-2006, 11:30 AM
|
#1
|
Status: Simply to simplify
Join date: Apr 2005
Location: Foxton, Manawatu, New Zealand
Expertise:
Software:
Posts: 5,572
|
Page titles when using php
Hi all,
As stated before I am a complete noob at .php.
I have used .php to insert site wide includes via:
<?php
include("includes/filename.html")
?>
This has been for meta tags, headers, navigation and footers.
Because I have .php includes does it mean I have to rename all my pages to .php instead of .html? Or can I leave them as .html?
Thank you very much in advance for your help
|
|
05-10-2006, 12:33 PM
|
#2
|
Status: I love this place
Join date: Jan 2005
Location: UK, Birmingham
Expertise:
Software:
Posts: 606
|
The file which contains the actual php code need to be .php unless you configure your server to read html pages as php pages but thats something different.
The pages which will be included (i.e. filename.html) do not need to be .php they can be .html]
I hope that made some sense.
edit: w00t 600 posts
|
|
05-10-2006, 06:12 PM
|
#3
|
Status: Member
Join date: Mar 2006
Location: Canada
Expertise:
Software:
Posts: 286
|
Files with php tags generally require the .php extension to be used.
If you're using PHP for the sole purpose of including other files, you can use HTML includes instead.
Code:
<!--#include file="includes/filename.html" -->
By using the above you can keep your .html extensions.
|
|
05-11-2006, 05:27 AM
|
#4
|
Status: Simply to simplify
Join date: Apr 2005
Location: Foxton, Manawatu, New Zealand
Expertise:
Software:
Posts: 5,572
|
Never heard of html includes before, wow, I am going to test it.
I also thought the browser never reads anything from inside the comments tag?
|
|
05-11-2006, 05:39 AM
|
#5
|
Status: I love this place
Join date: Mar 2005
Location:
Expertise:
Software:
Posts: 640
|
It's called SSI (Server Side Includes), my suggestion is use PHP and mod_rewrite if available. It's really simple to write the rewrite. I dislike SSI personally and just converted 4 sites I purchased from SSI into PHP. First off its not as scalabel, but you can always argue that you dont need any other power besides includes, second it's slower performance wise. There's probably more reasons but thats just a few..
|
|
05-11-2006, 05:42 AM
|
#6
|
Status: Simply to simplify
Join date: Apr 2005
Location: Foxton, Manawatu, New Zealand
Expertise:
Software:
Posts: 5,572
|
|
|
05-11-2006, 12:04 PM
|
#7
|
Status: Member
Join date: Apr 2006
Location:
Expertise:
Software:
Posts: 186
|
you can change the htaccess file on your server(or create one) to make your server read html as php. Therefore your main page or something doesn't have to be in php to do a php include.
sometimes your server htaccess file needs a different variation of this line of code.
Code:
AddType application/x-httpd-php .html .htm
that article is very confusing btw lol
|
|
05-17-2006, 04:13 PM
|
#8
|
Status: Member
Join date: Aug 2005
Location: New York
Expertise:
Software:
Posts: 105
|
If you're already using php, I would suggest just using PHP includes... As said, you can include any file type...I often give just give things I'm including a .inc extension, because it makes no difference to PHP but makes it easier for me to find things.
No need to go crazy with htaccess stuff.
|
|
05-17-2006, 09:00 PM
|
#9
|
Status: Member
Join date: May 2006
Location:
Expertise:
Software:
Posts: 197
|
Someone already mentioned SSI and I too believe that is the best solution for the situation you've described. However I want to point out something for the benefit of anyone who may be using includes for something a little more complex.
The PHP include function will include any type of file also, no matter what extension, read it as text, then process any php that may be present.
There is a big however. If you include a PHP file that has any php code in it but is not named with an extension that is PHP processed by Apache, that information will be available as clear text if directly accessed. Let me explain by example.
This is how I learned the hard way years ago! The situation: I had an index.php that included header.inc. I thought it would be a good idea to name all of my include files .inc to be consistant and help organize the files.
Inside header.inc, I connected to a database which requires username and password to be inside a function to connect to a database.
I found out that if anyone typed in header.inc directly into the browser instead of going to index.php, the entire contents of the code showed up as the default plain text. In other words, my username and password for the database were clearly visible.
Just something to keep in mind, it doesn't sound like you're using this to include any type of processed information, but if in the future you do you'll want to make sure that whatever file type you use as an include is processed for php via apache to keep it from displaying as clear text.
Using .inc as an include extension is farily common, you just have to know what you're doing. For instance one workaround is to add the extension .inc to the list of PHP files that apache processes.
|
|
05-20-2006, 08:22 AM
|
#10
|
Status: I love this place
Join date: May 2006
Location:
Expertise:
Software:
Posts: 603
|
Originally Posted by Julian
Never heard of html includes before, wow, I am going to test it.
I also thought the browser never reads anything from inside the comments tag?
|
Me neither, I never used includes though I just put the html on the actual php page.
|
|
|
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|