PHP 8.6.0 Beta 1 is available for testing

Voting

: min(three, four)?
(Example: nine)

The Note You're Voting On

nowfel dot terki at mailfence dot com
4 years ago
Be aware that if needle is an empty string, mb_stristr return the haystack by default.

For exemple:

<?php
if (mb_stristr("foo", "")) {
    echo "We enter in condition";
}
?>

Because in the above exemple the return of mb_stristr is "foo".

So if we do not want this kind of behaviour, we must set the third argument, ($before_needle) to true.

<?php
if (mb_stristr("foo", "", true)) {
    echo "We do not enter in condition";
}
?>

It can be useful to know it, specially when needle is dynamic.

<< Back to user notes page

To Top