From: Patrick Moloney
> I have a simple web site with a simple page that all works well, 
> although I have had a similar problem a couple of times that seems to
> caused by Comment Lines in the included files. I wonder if I have it 
> entirely right.
> All my files are .php files, but almost all the code is HTML.
> The file for my Web page is a complete HTML document, the file is
> The web page file "Includes" a few other files by putting the Include 
> statement in PHP tags, all by itself. The problem file contains the
> as the include. I made a change to the menu, that works, but I added a

> line with a comment at the top, which causes problems. The menu is
> like text.
> The first few lines in my menu file, menu.php, are comments using HTML

> syntax. The menu file has on UL and LI tags for the menu items - no 
> HTML, BODY etc. So I have a line of PHP in my web page file calling a 
> .php file where the first 2 lines are HTML comments. It was working
> 2 comment lines, the failed with 3 lines. Even when it fails the 
> remainder of the page displays ok although it is down lower because of

> the menu being displayed as text. I remove the comment it works.
> Does PHP preprocess the file but treat the comments as text because I 
> never said it was HTML? Would PHP comments have to be inside PHP tags?
> Am I correct in having just a fragment of HTML in the included file 
> without the entire HTML organization? I'd like to have comments in the

This is one detail that I have not seen a good explanation for. When PHP
opens an included file, it defaults back to HTML mode. You must have the
PHP tags to force it into PHP mode. This is true no matter what file
extension you have on them. So if you want to use PHP style comments,
you must wrap them with the proper tags.

Bob McConnell

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to