PHP4/Apache: .php files OK, <?php fails
| From: | The Big Ugly | Date: | Sun, 07 Jan 2001 11:01:01 +0000 |
| Subject: | PHP4/Apache: .php files OK, <?php fails | ||
| Groups: | php.install | ||
| Request: | Send a blank email to php-install+get-1483@lists.php.net to get a copy of this message | ||
I just installed PHP 4.0.4 on Apache 1.3.14 running on RH Linux 7.0 (i386)
and it's all looking pretty good, except that the inline <?php tags don't
work. A file ending in .php is recognized just fine by Apache and
executed properly.
That is, if I write a little PHP script and put it in a file with
extension .php, and load that into my browser, then it runs just like it
should.
If I have an HTML file with some of what I'll call "inline" PHP, using the
<?php ?> construct, the server & browser completely ignore it. I can view
the page source and see the PHP code; it is just getting ignored as if it
were an unknown HTML tag.
For example, this (test1.htm) does not work:
<html>
<head><title>Inline PHP</title><head>
<body>
Some stuff before the PHP<br>
<?php echo("a line printed by PHP"); ?><br>
</body>
</html>
All I get in the browser is the "Some stuff before the PHP" line.
This, on the other hand, does work when saved as test2.php and loaded
into the browser:
<?php
$html = <<<ENDH
<html>
<head><title>PHP from Script</title></head>
<body>
<h1>Groovy PHP</h1>
</body>
</html>
ENDH;
echo $html;
?>
So, I'm mystified. PHP and Apache seem to be talking together to some
extent, since the .php files work. Is there something I need to do to
enable the <?php ?> tags? I have tried the short <? ?> and long <script
language="php"> variations with the same results.
Thanks for any help!
Terry McKiernan
Ugly Software