Annotation of embedaddon/php/ext/pcre/tests/bug44214_2.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #44214-2 (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[0];
! 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: string(3) "aaa"
! 23: [1]=>
! 24: string(3) "aaa"
! 25: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>