ID: 17277
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Bogus
Bug Type: Strings related
Operating System: Linux
PHP Version: 4.2.1
New Comment:
You're missing something indeed, _$needle_ is equivalent with "." .
${"needle_"} as underscores can be part of a variablename.
As $needle_ is empty, the needle evaluates to "_", which is in "Moo
_bar_"
Not a bug > bogus.
Derick
Previous Comments:
------------------------------------------------------------------------
[2002-05-16 17:15:55] [EMAIL PROTECTED]
_$ doesn't have anysignificance, but that trailing _ does,
since it will try to match $needle_ as the variable name
and that will be empty.
------------------------------------------------------------------------
[2002-05-16 17:10:47] [EMAIL PROTECTED]
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 this bug report at http://bugs.php.net/?id=17277&edit=1