Web Develop Forum: Includes In HTML - Web Develop Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Includes In HTML Rate Topic: -----

#1 User is offline   the matt Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 65
  • Joined: 15-January 09
  • Gender:Male
  • Location:San Diego, CA

Posted 28 January 2009 - 07:52 PM

I just discovered that you can use includes in HTML tongue.gif

CODE
<!--#include virtual="path to file/include-file.html" -->


I've always just used PHP for includes...

Does anyone use this method for simple websites? Are there any benefits or drawbacks?
0

#2 User is offline   Diffraction Icon

  • Advanced Member
  • Icon
  • Group: Moderator
  • Posts: 279
  • Joined: 26-January 09
  • Gender:Male
  • Location:USA
  • Interests:Web Development, Reading, Writing, Computers in general...
  • Your specialities (detailed)::HTML 5
    CSS 3
    jQuery

Posted 28 January 2009 - 07:57 PM

QUOTE (the matt @ Jan 28 2009, 12:52 PM) <{POST_SNAPBACK}>
I just discovered that you can use includes in HTML tongue.gif

CODE
<!--#include virtual="path to file/include-file.html" -->


I've always just used PHP for includes...

Does anyone use this method for simple websites? Are there any benefits or drawbacks?


PHP has an advantage.. Say you make a website with HTML includes, and at a later date you want to add more functionality, you would use PHP... So if you used PHP includes you would already have the extension of .php

Make sense?

Also, PHP includes are even simpler then the html ones, laugh.gif

CODE
<?php include ('file.php'); ?>

Want to report something to a moderator? Use the 'report' button located on every post.
0

#3 User is offline   the matt Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 65
  • Joined: 15-January 09
  • Gender:Male
  • Location:San Diego, CA

Posted 28 January 2009 - 08:06 PM

Yea that's true.

I guess I was just amazed that you could do HTML includes. I could have just used HTML instead of changing everything to PHP on some sites I've done in the past.
0

#4 User is offline   Diffraction Icon

  • Advanced Member
  • Icon
  • Group: Moderator
  • Posts: 279
  • Joined: 26-January 09
  • Gender:Male
  • Location:USA
  • Interests:Web Development, Reading, Writing, Computers in general...
  • Your specialities (detailed)::HTML 5
    CSS 3
    jQuery

Posted 28 January 2009 - 08:07 PM

QUOTE (the matt @ Jan 28 2009, 01:06 PM) <{POST_SNAPBACK}>
Yea that's true.

I guess I was just amazed that you could do HTML includes. I could have just used HTML instead of changing everything to PHP on some sites I've done in the past.


True.
Want to report something to a moderator? Use the 'report' button located on every post.
0

#5 User is offline   Salathe Icon

  • Advanced Member
  • Icon
  • Group: Moderator
  • Posts: 138
  • Joined: 15-January 09
  • Gender:Male
  • Location:Scotland

Posted 28 January 2009 - 08:15 PM

You're referring to SSI. Not all servers will parse .html files for these includes (their normal extension is .shtml). See the Server Side Includes Wikipedia page for a brief overview and some handy reference links.
salathe@php.net
0

#6 User is offline   the matt Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 65
  • Joined: 15-January 09
  • Gender:Male
  • Location:San Diego, CA

Posted 28 January 2009 - 09:42 PM

So pretty much you can use .html and if your web server doesn't recognize this, use .shtml?
0

#7 User is offline   Vizon Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 7
  • Joined: 22-January 09
  • Gender:Male
  • Location:Indianapolis, Indiana

Posted 29 January 2009 - 02:28 AM

Wow, lol. I have never seen this..
0

#8 User is offline   Gaz Icon

  • Advanced Member
  • Icon
  • Group: Administrators
  • Posts: 178
  • Joined: 15-January 09
  • Gender:Male
  • Location:UK

Posted 29 January 2009 - 10:50 AM

Cool! I know it might seem odd but i think i would prefer to just stick a .php on the end of the file and use PHP's include method...
0

#9 User is offline   Sam Granger Icon

  • Administrator
  • PipPipPip
  • Group: Root Admin
  • Posts: 431
  • Joined: 22-October 08
  • Gender:Male

Posted 29 January 2009 - 11:47 AM

Or just use htaccess so people don't see it's .shtml or .php
0

#10 User is offline   the matt Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 65
  • Joined: 15-January 09
  • Gender:Male
  • Location:San Diego, CA

Posted 29 January 2009 - 09:02 PM

QUOTE (Sam Granger @ Jan 29 2009, 03:47 AM) <{POST_SNAPBACK}>
Or just use htaccess so people don't see it's .shtml or .php


How would I do that? Do you have a link or something?
0

#11 User is offline   Sam Granger Icon

  • Administrator
  • PipPipPip
  • Group: Root Admin
  • Posts: 431
  • Joined: 22-October 08
  • Gender:Male

Posted 29 January 2009 - 10:08 PM

This is just from the top of my head but it should work.

For PHP:
CODE
RewriteEngine on
RewriteRule ^(.*)\.html $1\.php


For SHTML
CODE
RewriteEngine on
RewriteRule ^(.*)\.html $1\.shtml

0

#12 User is offline   the matt Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 65
  • Joined: 15-January 09
  • Gender:Male
  • Location:San Diego, CA

Posted 29 January 2009 - 11:59 PM

Wow, thanks Sam smile.gif
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users