|
Posted by "Richard Lynch" on 10/29/05 22:28
On Sat, October 29, 2005 12:01 pm, Don Brown wrote:
> We're having a problem getting more than one imbedded PHP script to
> execute in our Apache-served pages. We're using Apache 2.0.40
> server-side includes. We wish to include multiple PHP scripts into our
> pages but are only succeeding in having the first included PHP script
> executed; the rest are ignored or misinterpreted as HTML...
>
> Thank you in advance for any help you provide.
>
>
> This works:
>
> $ cat php1.txt
> <?php
> echo "this is the first php include";
> ?>
> $ cat test.shtml
> <html><body>
>
> <!--#INCLUDE virtual="/php1.txt"-->
You are using Server Side Include (SSI) here.
SSI is to PHP as a GoCart is to a Ferrarri :-)
*IF* your original page of HTML can be parsed as PHP, you'll have a
lot less frustration and a lot more flexibility using:
<?php include 'php1.txt'?>
instead.
But let's assume that you are:
A) Stuck with the HTML being HTML.
B) Don't need variables/data from php1.txt to transfer to php2.txt
later in the script
C) Are willing to accept the increased HTTP performance hit of <!--
#INCLUDE virtual...> which, I *THINK* will chew up another HTTP
connection
If you're okay with all of that, you probably just need to change
php1.txt to php1.php so that when it is requested, Apache "knows" that
it is PHP code, and not plain text.
*.txt -> Apache mime-type makes Apache think it's plain/text
*.php -> Apache mime-type makes Apache think it's PHP
These are just the defaults.
You can configure Apache with ForceType (and friends) to make all your
..txt files pass through PHP, or all your .htm or .html files pass
through PHP.
Whether you really WANT to pass *ALL* .txt files through PHP is pretty
questionable.
All .htm and .html files through PHP is quite common and has many
benefits.
PS I got no idea how you managed to get the FIRST php block to work
and not the second... Unless one of them has .php as part of the
filename
--
Like Music?
http://l-i-e.com/artists.htm
Navigation:
[Reply to this message]
|