Re: curious (and frustrating) php/apache behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

why don't you use normal php include (require) functions? Why do you want to mix apache server side includes with php code? There is nothing php include can't do..

Just change all

<!--#INCLUDE virtual="xxxx"-->

to

<? include('xxxx'); ?>

Petr

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"-->

<br>this came from html

</body></html>

Producing the expected result from the browser (http://myhost/test.shtml):
this is the first php include this is html
However, this does not produce the expected three line result:

$ cat php1.txt
<?php
echo "this is the first php include";
?>
$ cat php2.txt
<?php
echo "this is the second php include";
?>
$ cat test.shtml
<html><body>

<!--#INCLUDE virtual="/php1.txt"-->
<br>
this came from html
<br>
<!--#INCLUDE virtual="/php2.txt"-->

</body></html>

Producing from the browser (http://myhost/test.shtml):
this is the first php include this is html

This DOES work:

$cat test.php
<html><body>

<?php
echo "this is from the first php block";
?>

<br>
this is from html
<br>

<?php
echo "this is from the second php block";
?>

</body></html>

Producing from the browser (http://myhost/test.shtml):
this is from the first php block this is from html this is from the second php block

Don Brown
Co-Founder, Utah Skies
"Ski champagne powder by day, surf diamond-studded velvet by night..."


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux