1--TEST-- 2preg_replace_callback_array() basic functions 3--FILE-- 4<?php 5 6class Rep { 7 public function __invoke() { 8 return "d"; 9 } 10} 11 12class Foo { 13 public static function rep($rep) { 14 return "ok"; 15 } 16} 17 18function b() { 19 return "b"; 20} 21 22var_dump(preg_replace_callback_array( 23 array( 24 "/a/" => 'b', 25 "/b/" => function () { return "c"; }, 26 "/c/" => new Rep, 27 '/d/' => array("Foo", "rep")), 'a')); 28 29var_dump(preg_replace_callback_array( 30 array( 31 "/a/" => 'b', 32 "/c/" => new Rep, 33 "/b/" => function () { return "ok"; }, 34 '/d/' => array("Foo", "rep")), 'a')); 35 36var_dump(preg_replace_callback_array( 37 array( 38 '/d/' => array("Foo", "rep"), 39 "/c/" => new Rep, 40 "/a/" => 'b', 41 "/b/" => function($a) { return "ok"; }), 'a', -1, $count)); 42var_dump($count); 43 44var_dump(preg_replace_callback_array( 45 array('/a/' => 'b', "/c/" => new Rep), 46 array('a', 'c'))); 47 48?> 49--EXPECT-- 50string(2) "ok" 51string(2) "ok" 52string(2) "ok" 53int(2) 54array(2) { 55 [0]=> 56 string(1) "b" 57 [1]=> 58 string(1) "d" 59} 60