You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Anthony G. Atkielski" <an...@atkielski.com> on 2005/01/13 11:53:28 UTC

[users@httpd] To what extent can SSI and PHP be combined?

Is there any way to get #includes with SSI expanded inside a page that
has a PHP extension, or, conversely, any way to get PHP to execute when
it is brought into a page via #include?

I'm having a lot of trouble with pages that require some sort of PHP
coding, as I also want to use SSI to bring in standard parts of the
page, but I can't figure out if or how they can both be combined.

Any pointers to what's allowed or possible?  My Web search has been
inconclusive.  My impression is that #include files can't contain PHP
code, and PHP pages cannot contain #includes.  PHP has its own include
function, of course, but this apparently doesn't expand the included
file the way SSI does, it just reads it into the current page.  And SSI
will expand a file with #include, but it won't give it to PHP, so any
PHP code is ignored.

Are there any solutions to this problem?

-- 
Anthony



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] To what extent can SSI and PHP be combined?

Posted by Rich Bowen <rb...@rcbowen.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Anthony G. Atkielski wrote:
| Rich Bowen writes:
|
|>You can do this with Apache 2.0. It's called "Filter Chains". With 1.3,
|>however, it's not possible.
|>
|>http://httpd.apache.org/docs-2.0/filter.html for more details.
|
| I'm running 2.0, so I guess I can do it--but the page you point to is
| only a single paragraph.

Well, yes, but following the links from that page leads to examples of
exactly what you're trying to do.

| What directives should I use to allow #include to invoke PHP for
| included files that end in .php, and to allow PHP files ending in .php
| to expand any embedded #include directives?

Another related example can be seen here:

http://www.apache.org/~rbowen/presentations/apachecon2004/apache2.0/slide9.html

~    AddHandler cgi-script cgi
~    AddOutPutFilter INCLUDES cgi

In your specific case, that would look something like:

	AddHandler application/x-httpd-php php
	AddOutputFilter INCLUDES php

- --
The night has a thousand saxophones.
So get out there and rock.
~        Roll the Bones - Rush
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFB6QsaXP03+sx4yJMRAj6YAJ0TppVxxIPv/2cJwbUH7I3/PKQvlQCcDLod
IrjXimlHcnOottkHoJ2UDmg=
=/ur0
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] To what extent can SSI and PHP be combined?

Posted by "Anthony G. Atkielski" <an...@atkielski.com>.
Rich Bowen writes:

> You can do this with Apache 2.0. It's called "Filter Chains". With 1.3,
> however, it's not possible.
>
> http://httpd.apache.org/docs-2.0/filter.html for more details.

I'm running 2.0, so I guess I can do it--but the page you point to is
only a single paragraph.

What directives should I use to allow #include to invoke PHP for
included files that end in .php, and to allow PHP files ending in .php
to expand any embedded #include directives?

It would save me a mountain of time if I could get these to work
simultaneously, as I have some pages that are seriously kludged because
I've never been able to do both for the same page.

-- 
Anthony



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] To what extent can SSI and PHP be combined?

Posted by Rich Bowen <rb...@rcbowen.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Anthony G. Atkielski wrote:
| Is there any way to get #includes with SSI expanded inside a page that
| has a PHP extension, or, conversely, any way to get PHP to execute when
| it is brought into a page via #include?
|
| I'm having a lot of trouble with pages that require some sort of PHP
| coding, as I also want to use SSI to bring in standard parts of the
| page, but I can't figure out if or how they can both be combined.
|
| Any pointers to what's allowed or possible?  My Web search has been
| inconclusive.  My impression is that #include files can't contain PHP
| code, and PHP pages cannot contain #includes.  PHP has its own include
| function, of course, but this apparently doesn't expand the included
| file the way SSI does, it just reads it into the current page.  And SSI
| will expand a file with #include, but it won't give it to PHP, so any
| PHP code is ignored.
|
| Are there any solutions to this problem?

You can do this with Apache 2.0. It's called "Filter Chains". With 1.3,
however, it's not possible.

http://httpd.apache.org/docs-2.0/filter.html for more details.

- --
Oh I have slipped the surly bonds of earth
And danced the sky on laughter-silvered wings
~ --High Flight (John Gillespie Magee)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFB5nZZXP03+sx4yJMRAh5mAJ90554OQnyX1ZGv0AluTHVNoM12cQCgifY5
ZoCQWmuo8SKas4fRAgXyf+o=
=JBnr
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org