PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 300,485 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,779 people online right now. Registration is fast and FREE... Join Now!




issues with SSI includes

 

issues with SSI includes

arthurakay

29 Jun, 2009 - 08:55 AM
Post #1

D.I.C Head
**

Joined: 17 Feb, 2009
Posts: 184



Thanked: 16 times
My Contributions
I'm using IIS7 to run a website which my client wants in PHP, and I've run into an annoying issue.

I can easily include fragment files via the PHP include() method, but it gets complicated when files are not at the root level of the website. I've been trying to use (1) the standard SSI include and (2) the PHP virtual() method, but in both cases my fragment files aren't being included.

Note: my page ends in a .php extension.

In the first case (SSI includes), I'm using the following code:
CODE
<!--#include virtual="/x/y/z.ssi" -->


The server (IIS7) simply ignores this code and interprets that line as an HTML comment. This exact code works fine when running ASP.NET, so I don't know if it's a PHP setting.

In the second case, (using PHP virtual() method), I get this error: Fatal error: Call to undefined function: virtual()

I need to use virtual includes in my particular case... has anyone ever encountered this? (I'm running a shared hosting account through GoDaddy if that's important)

User is offlineProfile CardPM
+Quote Post


AdaHacker

RE: Issues With SSI Includes

29 Jun, 2009 - 03:06 PM
Post #2

D.I.C Regular
***

Joined: 17 Jun, 2008
Posts: 378



Thanked: 83 times
My Contributions
QUOTE(arthurakay @ 29 Jun, 2009 - 10:55 AM) *
The server (IIS7) simply ignores this code and interprets that line as an HTML comment.

Well, PHP doesn't interpret SSI directives. The server is probably passing the file straight to the PHP interpreter rather than doing the SSI first. It might be possible to configure the server to filter the file through the engine that handles SSI and then pass the result off to PHP, or vice versa. Then again, it might not be. I really don't know enough about IIS to be able to tell you.

QUOTE
In the second case, (using PHP virtual() method), I get this error: Fatal error: Call to undefined function: virtual()

Read the documentation: virtual() is an Apache-specific function. If you're running IIS, it's not going to be available. You'll just have to use another method.
User is offlineProfile CardPM
+Quote Post

baavgai

RE: Issues With SSI Includes

29 Jun, 2009 - 04:07 PM
Post #3

Dreaming Coder
Group Icon

Joined: 16 Oct, 2007
Posts: 4,261



Thanked: 389 times
Dream Kudos: 550
Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua, Cheese

My Contributions
QUOTE(arthurakay @ 29 Jun, 2009 - 10:55 AM) *

This exact code works fine when running ASP.NET, so I don't know if it's a PHP setting.


I find this hard to believe. It's Apache only. You can look into to putting some directives in the .htaccess, assuming godaddy is running Apache and honors local configurations.

However, it's rare to see SSI and PHP combined. If you're going through the effort of processing the page through PHP, it doesn't make sense to use SSI.

User is offlineProfile CardPM
+Quote Post

arthurakay

RE: Issues With SSI Includes

30 Jun, 2009 - 05:22 AM
Post #4

D.I.C Head
**

Joined: 17 Feb, 2009
Posts: 184



Thanked: 16 times
My Contributions
Thanks guys. I'm definitely more of a .NET developer, so I appreciate you pointing out the Apache-specific PHP stuff. I just find it odd (frustrating really) that PHP isn't the same on IIS and Linux, though I guess I shouldn't be surprised.

Using SSIs to include file fragments has been something I've done for a long time, and I've worked in Linux environments where this works fine with PHP (I didn't setup the servers). I typically use ASP.NET (and PHP) for data access and business logic, and the SSIs for stitching-together the pieces of my web templates. Thus, if you swapped languages (or servers) the SSIs would remain intact, and you'd only be looking to rewrite the language-specific logic. That is what I've attempted to do in this case. Since I'm using a shared hosting account on IIS, it's pretty clear that the default server settings don't allow me to use SSI within PHP. I'll have to figure something else out.

Thanks again!
User is offlineProfile CardPM
+Quote Post

eric788

RE: Issues With SSI Includes

8 Jul, 2009 - 05:39 AM
Post #5

New D.I.C Head
*

Joined: 8 Jul, 2009
Posts: 1

You can use php includes (another form of SSI). They just have a slightly different syntax. With the .php extension on the file - these includes will be handled just as they are in IIS with SSI- except PHP will be doing the work.

<?php include("myincludepathgoeshere.inc"); ?>


QUOTE(arthurakay @ 30 Jun, 2009 - 05:22 AM) *

Thanks guys. I'm definitely more of a .NET developer, so I appreciate you pointing out the Apache-specific PHP stuff. I just find it odd (frustrating really) that PHP isn't the same on IIS and Linux, though I guess I shouldn't be surprised.

Using SSIs to include file fragments has been something I've done for a long time, and I've worked in Linux environments where this works fine with PHP (I didn't setup the servers). I typically use ASP.NET (and PHP) for data access and business logic, and the SSIs for stitching-together the pieces of my web templates. Thus, if you swapped languages (or servers) the SSIs would remain intact, and you'd only be looking to rewrite the language-specific logic. That is what I've attempted to do in this case. Since I'm using a shared hosting account on IIS, it's pretty clear that the default server settings don't allow me to use SSI within PHP. I'll have to figure something else out.

Thanks again!


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 04:07AM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month