Annotation of embedaddon/php/ext/mbstring/tests/mb_substr_count_variation4.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test mb_substr_count() function : variation - pass a $needle that overlaps in $haystack
        !             3: --SKIPIF--
        !             4: <?php
        !             5: extension_loaded('mbstring') or die('skip');
        !             6: function_exists('mb_substr_count') or die("skip mb_substr_count() is not available in this build");
        !             7: ?>
        !             8: --FILE--
        !             9: <?php
        !            10: /* Prototype  : int mb_substr_count(string $haystack, string $needle [, string $encoding])
        !            11:  * Description: Count the number of substring occurrences 
        !            12:  * Source code: ext/mbstring/mbstring.c
        !            13:  */
        !            14: 
        !            15: /*
        !            16:  * Pass mb_substr_count() a $needle that overlaps in $haystack and see whether
        !            17:  * it counts only the first occurrence or all other occurrences regardless whether they
        !            18:  * were part of previous match
        !            19:  */
        !            20: 
        !            21: echo "*** Testing mb_substr_count() : usage variations ***\n";
        !            22: 
        !            23: 
        !            24: echo "\n-- ASCII String --\n";
        !            25: $string_ascii = b'abcabcabc';
        !            26: var_dump(mb_substr_count($string_ascii, b'abcabc')); //needle overlaps in haystack
        !            27: 
        !            28: echo "\n-- Multibyte String --\n";
        !            29: $string_mb = base64_decode('5pel5pys6Kqe5pel5pys6Kqe5pel5pys6Kqe');
        !            30: $needle_mb = base64_decode('5pel5pys6Kqe5pel5pys6Kqe');
        !            31: var_dump(mb_substr_count($string_mb, $needle_mb, 'utf-8'));
        !            32: 
        !            33: 
        !            34: echo "Done";
        !            35: ?>
        !            36: --EXPECTF--
        !            37: *** Testing mb_substr_count() : usage variations ***
        !            38: 
        !            39: -- ASCII String --
        !            40: int(1)
        !            41: 
        !            42: -- Multibyte String --
        !            43: int(1)
        !            44: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>