note 55149 added to function.preg-match
| From: | hippiejohn1020---attT---yahoo dot com at osu1 dot php dot net | Date: | Tue, 26 Jul 2005 16:38:36 +0000 |
| Subject: | note 55149 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92493@lists.php.net to get a copy of this message | ||
Watch out when using c-style comments around a preg_match or preg_* for that matter. In certain
situations (like example below) the result will not be as expected. This one is of course easy to
catch but worth noting.
/*
we will comment out this section
if (preg_match ("/anything.*/", $var)) {
code here;
}
*/
This is (I believe) because comments are interpreted first when parsing the code (and they should
be). So in the preg_match the asterisk (*) and the ending delimiter (/) are interpreted as the end
of the comment and the rest of your (supposedly commented) code is intrepreted as php.
----
Manual Page -- http://www.php.net/manual/en/function.preg-match.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55149
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55149&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55149&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55149&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55149&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55149&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55149&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55149&report=yes
Search -- http://master.php.net/manage/user-notes.php