Annotation of embedaddon/php/ext/mbstring/tests/mb_substr_error2.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test mb_substr() function : error conditions - Pass an unknown encoding
! 3: --SKIPIF--
! 4: <?php
! 5: extension_loaded('mbstring') or die('skip');
! 6: function_exists('mb_substr') or die("skip mb_substr() is not available in this build");
! 7: ?>
! 8: --FILE--
! 9: <?php
! 10: /* Prototype : string mb_substr(string $str, int $start [, int $length [, string $encoding]])
! 11: * Description: Returns part of a string
! 12: * Source code: ext/mbstring/mbstring.c
! 13: */
! 14:
! 15: /*
! 16: * Pass an unknown encoding to mb_substr() to test behaviour
! 17: */
! 18:
! 19: echo "*** Testing mb_substr() : error conditions ***\n";
! 20:
! 21: $str = 'Hello, world';
! 22: $start = 1;
! 23: $length = 5;
! 24: $encoding = 'unknown-encoding';
! 25:
! 26: var_dump( mb_substr($str, $start, $length, $encoding));
! 27:
! 28: echo "Done";
! 29: ?>
! 30: --EXPECTF--
! 31: *** Testing mb_substr() : error conditions ***
! 32:
! 33: Warning: mb_substr(): Unknown encoding "unknown-encoding" in %s on line %d
! 34: bool(false)
! 35: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>