Jump to content

PHP as virtual include (.shtml) displays 0


BlueSkyIS

Recommended Posts

Howdy!

 

A client's web page is .shtml and includes various PHP files via standard virtual include:

 

<!--#include virtual="session.php" -->

 

These PHP includes worked fine until recently, when PHP files that produce no visible output began displaying a 0 (zero). For instance, the session.php file above is here in it's entirety:

 

<?php
session_start();
?>

 

The include is on the first line of the .shtml file, and includes that bit of code, but displays a 0 in the browser. If I echo anything at all the 0 goes away, but of course we don't want to echo anything before the <html> tag in the .shtml file. The short-term and unacceptable solution is to echo an empty HTML comment, as follows:

 

<?php
session_start();
echo "<!-- -->";
?>

 

As noted, this causes the 0 to disappear but now we have <!-- --> before the HTML.

 

Repeat: This was not happening when the .shtml and PHP was installed, and the files have not changed. Therefore, it seems that this problem is caused by a change in PHP and/or Apache configuration.

 

Has anyone seen this and/or can anyone explain what's going on?

 

Thanks!

 

 

Link to comment
https://forums.phpfreaks.com/topic/218211-php-as-virtual-include-shtml-displays-0/
Share on other sites

Thanks for the help, but that did not solve the problem. Everything was working fine for at least a month or two, then suddenly 0 started showing up unless we echo something. I added that header and removed the ehco, and 0 showed up again. good fun!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.