From: [EMAIL PROTECTED]
Operating system: Linux
PHP version: 4.2.1
PHP Bug Type: Strings related
Bug description: strstr matches any variable surrounded by underscores
This script:
<?php
$needle = "foo";
echo "1: ";
echo strstr("Moo _bar_", "_$needle_");
echo "<br>2: ";
echo strstr("Moo _bar_", "_{$needle}_");
echo "<br>3: ";
echo strstr("Moo _foo_", "_{$needle}_");
echo "<br>4: ";
echo strstr("Moo !bar!", "!$needle!");
?>
Gives this output:
1: _bar_
2:
3: _foo_
4:
Obviously, the line 1 is the problem. If both "haystack" and "needle" have
the strings surrounded by underscores - the strings are matched even if
they are actually different. This happens only if the "needle" has a
variable between the underscores, and the variable is not surrounded by {
and }.
Prehaps I am missing something and the combination of "_$" is supposed to
mean something, but i did not see it in the documentation.
--
Edit bug report at http://bugs.php.net/?id=17277&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=17277&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=17277&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=17277&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=17277&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17277&r=support
Expected behavior: http://bugs.php.net/fix.php?id=17277&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=17277&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=17277&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=17277&r=globals