Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1324 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Page titles when using php

Thread title: Page titles when using php
Closed Thread  
Page 1 of 2 1 2 >
    Thread tools Search this thread Display Modes  
05-10-2006, 11:30 AM
#1
Julian is offline Julian
Status: Simply to simplify
Join date: Apr 2005
Location: Foxton, Manawatu, New Zealand
Expertise:
Software:
 
Posts: 5,572
iTrader: 0 / 0%
 

Julian is on a distinguished road

  Old  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
opserty is offline opserty
Status: I love this place
Join date: Jan 2005
Location: UK, Birmingham
Expertise:
Software:
 
Posts: 606
iTrader: 0 / 0%
 

opserty is on a distinguished road

Send a message via MSN to opserty

  Old

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
DJAC is offline DJAC
DJAC's Avatar
Status: Member
Join date: Mar 2006
Location: Canada
Expertise:
Software:
 
Posts: 286
iTrader: 0 / 0%
 

DJAC is on a distinguished road

Send a message via MSN to DJAC

  Old

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
Julian is offline Julian
Status: Simply to simplify
Join date: Apr 2005
Location: Foxton, Manawatu, New Zealand
Expertise:
Software:
 
Posts: 5,572
iTrader: 0 / 0%
 

Julian is on a distinguished road

  Old

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
sysblnk is offline sysblnk
Status: I love this place
Join date: Mar 2005
Location:
Expertise:
Software:
 
Posts: 640
iTrader: 0 / 0%
 

sysblnk is on a distinguished road

  Old

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
Julian is offline Julian
Status: Simply to simplify
Join date: Apr 2005
Location: Foxton, Manawatu, New Zealand
Expertise:
Software:
 
Posts: 5,572
iTrader: 0 / 0%
 

Julian is on a distinguished road

  Old

Awesome, just read a great article on html server side includes:
http://http-server.carleton.ca/~dmcf...i.html#include

For it to run you have to edit your .htaccess file.

05-11-2006, 12:04 PM
#7
mason is offline mason
mason's Avatar
Status: Member
Join date: Apr 2006
Location:
Expertise:
Software:
 
Posts: 186
iTrader: 0 / 0%
 

mason is on a distinguished road

  Old

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
gluc0se is offline gluc0se
Status: Member
Join date: Aug 2005
Location: New York
Expertise:
Software:
 
Posts: 105
iTrader: 0 / 0%
 

gluc0se is on a distinguished road

Send a message via AIM to gluc0se Send a message via MSN to gluc0se

  Old

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
jjmac is offline jjmac
jjmac's Avatar
Status: Member
Join date: May 2006
Location:
Expertise:
Software:
 
Posts: 197
iTrader: 0 / 0%
 

jjmac is on a distinguished road

  Old

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
crazyryan is offline crazyryan
Status: I love this place
Join date: May 2006
Location:
Expertise:
Software:
 
Posts: 603
iTrader: 6 / 100%
 

crazyryan is an unknown quantity at this point

  Old

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.

Closed Thread  
Page 1 of 2 1 2 >


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed