Annotation of embedaddon/php/ext/pcre/tests/bug44214.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #44214 (crash with preg_replace_callback() and global variable)
! 3: --FILE--
! 4: <?php
! 5: $string = 'aaa bbb ccc ddd eee ccc aaa bbb';
! 6:
! 7: $array = array();
! 8:
! 9: function myCallBack( $match ) {
! 10: global $array;
! 11: $array[] = $match;
! 12: return 'xxx';
! 13: }
! 14:
! 15: var_dump(preg_replace_callback( '`a+`', 'myCallBack', $string));
! 16: var_dump($array);
! 17: ?>
! 18: --EXPECT--
! 19: string(31) "xxx bbb ccc ddd eee ccc xxx bbb"
! 20: array(2) {
! 21: [0]=>
! 22: array(1) {
! 23: [0]=>
! 24: string(3) "aaa"
! 25: }
! 26: [1]=>
! 27: array(1) {
! 28: [0]=>
! 29: string(3) "aaa"
! 30: }
! 31: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>