Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter psicosi448

    (@psicosi448)

    No reason to check if $needle === “”.

    endsWith has to check:
    1) $haystack lenght > 0
    2) strlen($haystack)>=strlen($needle)
    3) strpos !== FALSE

    return strlen($haystack) && ($len=strlen($haystack)-strlen($needle)) >= 0 && strpos($haystack, $needle, $len) !== FALSE;

    Hope this helps and thanks for your plugin,
    F.

    Plugin Author thesp0nge

    (@thesp0nge)

    Hi @psicosy448 and thank you for the help.

    I’ll dig into it and fixing up the issue soon.
    Paolo

    Plugin Author thesp0nge

    (@thesp0nge)

    Should be fixed now.
    Can you try it?

    Thread Starter psicosi448

    (@psicosi448)

    Sure.
    I’ve tried 0.7 version.
    Now I’m seeing this warning:

    [22-Apr-2015 07:46:02 UTC] PHP Warning: substr_compare(): The start position cannot exceed initial string length in wordstress.php on line 99

    Plugin Author thesp0nge

    (@thesp0nge)

    I can’t reproduce it, nothing found in access.log 🙁
    I’ve got a WordPress 4.1.2 and PHP 5.4.38.

    Can you please share your info details?

    Thread Starter psicosi448

    (@psicosi448)

    I’m on a WP 4.1.2 and a PHP 5.4.35.

    It seems that strlen($haystack)===0 raise the Warning.
    Maybe the homepage ?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Annoying warning in endsWith()’ is closed to new replies.