php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9320 ?> is always the last (even in strings!!!)
Submitted: 2001-02-17 12:14 UTC Modified: 2001-03-06 07:03 UTC
From: goba@php.net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.3pl1 OS: win2k
Private report: No CVE-ID: None
 [2001-02-17 12:14 UTC] goba@php.net
See this code:

<?php
  echo "<?php echo 'test'; ?>";
?>

This works good. And prints:
<?php echo 'test'; ?>
which it should print.

Then using a comment:

<?php
  #echo "<?php echo 'test'; ?>";
?>

This prints: 

";

?>

The ?> is recognized in the string, although
it should not be recognized I think!!!

This is a problem if you generate php pages,
as Smarty does for expample... (phpinsider.com)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-17 13:02 UTC] derick@php.net
This is not a bug, but documented behaviour.
 [2001-02-17 13:13 UTC] goba@php.net
It is bug, bug and bug!!!

See the manual :

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

The thing echoed should not mean the end of
the block: 

1: <?php
2:   #echo "<?php echo 'test'; ?>";
3: ?>

The block starts on line 1 and ends
on line 3. I think we can agree on this.

BUT: the PHP parser thinks that the end of
code is on line 2, but this is just
one thing echoed, and not meant to be
parsed by this PHP parser...

The end of block is on line 3.

This is not documented!
 [2001-02-17 13:32 UTC] derick@php.net
Yep, you're right, it should not end with the ?> in a string
 [2001-03-06 07:03 UTC] stas@php.net
?> is recognized in comments, it's known  - in order to allow:
<some html><?php call_code(); // here we do stuff ?></some html>


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 05:01:27 2024 UTC