Re: Include File Errors with Comments

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

 



Patrick Moloney wrote:
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 be 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 .php. 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 menu 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 read 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 with 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 file.

If you're putting php comments outside php tags, they are treated as text (they're not inside php tags, it's not php).

The php tags tell php when to start parsing/processing the script. Without that, it passes it to your webserver to just display the content.

If that's not what you're doing post a short (very short - don't post your whole scripts) example of what you mean.

--
Postgresql & php tutorials
http://www.designmagick.com/


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