I'm experimenting around with Server Side Includes. I have them working fine using a .html extension.

Trial.html file is below:

<html>
  <body>
    <!--#include virtual="HelloWorld.html" -->
  </body>
</html>

The .htaccess file looks like this:

AddHandler server-parsed .shtml .html .htm
Options Indexes FollowSymLinks Includes

HelloWorld.html is just a single line:

Hello World

When you browse to Trial.html, It responds with Hello World , as I expected. Rename the file to Trial.php and navigate to that page and I get a blank screen (same code as Trial.html).

When I add the .php extension to the .htaccess file like this:

AddHandler server-parsed .shtml .html .htm .php
Options Indexes FollowSymLinks Includes

and browse to Trial.php, I get a popup window saying "You have chosen to open 'Trial.php'", then asking whether I want to save the file or open it with a program on my local machine. I want to do neither. I want it to display "Hello World" in the browser. Does anyone see what I am doing wrong? When I remove line 3 from Trial.php (the #include line), I get the same message.

When I leave the .php extension off in the .htaccess file and change Trial.php to this:

<html>
  <body>
    <?php include ("HelloWorld.html"); ?>
  </body>
</html>

it seems to work fine (displays "Hello World" to the browser), so that's what I'll do for now. But I am still curious why this isn't working:

<html>
  <body>
    <!--#include virtual="HelloWorld.html" -->
  </body>
</html>

Use one or the other, not both. PHP was originally used as a replacement for SSI bull. Bottom line is, don't use SSIs

Use one or the other, not both. PHP was originally used as a replacement for SSI bull. Bottom line is, don't use SSIs

I've been learning SSI because I read that framesets were bad and it was better to use SSI. You don't think SSI is good either? By "use one or the other, but not both", do you mean I should use HTML with SSI or PHP without SSI, but not PHP with SSI?

'framesets are bad ssi is better' - that tutorial is at least ten years old
current practice excludes ssi
php is far more developed, flexible, powerful than SSI,
ssi is redundant
nothing that ssi can do is not able to be done by php (asp for ms fans)
much that php can do is not able to be done by ssi
learn one use one (might as well be the one that does more)
ssi cannot compile itself a slideshow, php can
php reads and writes databases, sends mail.

This site is php
500 000+ users, millions of posts, millions of images, all a click away

'framesets are bad ssi is better' - that tutorial is at least ten years old
current practice excludes ssi
php is far more developed, flexible, powerful than SSI,
ssi is redundant
nothing that ssi can do is not able to be done by php (asp for ms fans)
much that php can do is not able to be done by ssi
learn one use one (might as well be the one that does more)
ssi cannot compile itself a slideshow, php can
php reads and writes databases, sends mail.

This site is php
500 000+ users, millions of posts, millions of images, all a click away

Time for me to find new tutorials then! I know nothing about framesets, little about SSI, but I've gotten pretty decent at PHP (apart, obviously, from including other files), so I guess the best bet is to improve my PHP skills. So this is the best way to go?

<html>
  <body>
    <?php include ("HelloWorld.html"); ?>
  </body>
</html>

I've included files using PHP before, but they've always been other PHP files with PHP functions. This has been my first attempt to include a straight HTML file. And are frames and framesets worth learning?

Thanks.

No, please avoid them like the plague. They're annoying, old, and rickety just like websites that use them. The only function they serve now are for hacks for file upload.

as well as tutorials at php.net and a hundred other sites

there are thousands of premade php scripts for download from sourceforge hotscripts phpscripts and hundreds of other repository sites, that may be lready to do what you require in many cases

Thanks guys.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.