note 92643 added to language.basic-syntax.phpmode
| From: | ravenswd at gmail dot com | Date: | Sun, 02 Aug 2009 00:08:12 +0000 |
| Subject: | note 92643 added to language.basic-syntax.phpmode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-158994@lists.php.net to get a copy of this message | ||
One aspect of PHP that you need to be careful of, is that ?> will drop you out of PHP code and
into HTML even if it appears inside a // comment. (This does not apply to /* */ comments.) This can
lead to unexpected results. For example, take this line:
<?php
$file_contents = '<?php die(); ?>' . "\n";
?>
If you try to remove it by turning it into a comment, you get this:
<?php
// $file_contents = '<?php die(); ?>' . "\n";
?>
Which results in ' . "\n"; (and whatever is in the lines following it) to be output
to your HTML page.
The cure is to either comment it out using /* */ tags, or re-write the line as:
<?php
$file_contents = '<' . '?php die(); ?' . '>' .
"\n";
?>
----
Server IP: 209.41.74.194
Probable Submitter: 67.165.168.203
----
Manual Page -- http://www.php.net/manual/en/language.basic-syntax.phpmode.php
Edit -- https://master.php.net/note/edit/92643
Del: integrated -- https://master.php.net/note/delete/92643/integrated
Del: useless -- https://master.php.net/note/delete/92643/useless
Del: bad code -- https://master.php.net/note/delete/92643/bad+code
Del: spam -- https://master.php.net/note/delete/92643/spam
Del: non-english -- https://master.php.net/note/delete/92643/non-english
Del: in docs -- https://master.php.net/note/delete/92643/in+docs
Del: other reasons-- https://master.php.net/note/delete/92643
Reject -- https://master.php.net/note/reject/92643
Search -- https://master.php.net/manage/user-notes.php