php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16948 include interprets commented php tags
Submitted: 2002-05-01 14:53 UTC Modified: 2002-05-02 14:49 UTC
From: steve at teamITS dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.1.2 OS: WinNT 4, IRIX64 vega 6.5 07091
Private report: No CVE-ID: None
 [2002-05-01 14:53 UTC] steve at teamITS dot com
I have a few PHP files that have a common header and footer which I pull in using an include().  After our web host upgraded from 4.0.6 to 4.1.2 I realized that include() was not working properly.

My included file had a section with PHP tags that was commented out, like:

//<?php
//echo "hello";
//?>
echo "hello2";

  4.0.6 would ignore these, but 4.1.2 ignores that there is a comment marker, and ends the PHP interpreter in the comment  line, sending the 'echo "hello2";' and remaining code as TEXT to the browser.  I am not sure if this qualifies as a bug but is definitely different that the behavior of 4.0.6 which ignored all commented lines.

I have duplicated this on a Windows NT 4 server also.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-01 15:00 UTC] derick@php.net
This is not a bug, see the manual:

http://www.php.net/manual/en/language.basic-syntax.comments.php

it says:
 The "one-line" comment styles actually only comment to the end of the line or the current block of PHP code, whichever comes first.

and ?> is the end of a php block, so it drops out of PHP mode there and continues in HTML mode.

AFAIK this also worked like this in 4.0.6 (and always in 4.x).

Derick
 [2002-05-02 09:00 UTC] tal@php.net
Marking as Bogus.

-Tal
 [2002-05-02 14:49 UTC] steve at teamITS dot com
Thank you for looking into this, and I did miss this in the manual.  However it was working fine for a long time with the previous version.  After some thought I realized that my original note was incorrect in a minor but significant way...the file had the ASP-style tags commented out ("%>").  I changed that to the "?>" tags and of course saw the same "problem."  So perhaps 4.0.6 stopped at all tags except the ASP-style tags.  In any case it sounds like it is a bogus report for 4.1.2, sorry.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 17:01:33 2024 UTC