xref: /PHP-5.4/ext/pcre/tests/preg_replace.phpt (revision 6fb763c4)
1--TEST--
2preg_replace()
3--FILE--
4<?php
5
6var_dump(preg_replace('{{\D+}}', 'x', '{abcd}'));
7var_dump(preg_replace('{{\D+}}', 'ddd', 'abcd'));
8
9var_dump(preg_replace('/(ab)(c)(d)(e)(f)(g)(h)(i)(j)(k)/', 'a${1}2$103', 'zabcdefghijkl'));
10
11var_dump(preg_replace_callback('//e', '', ''));
12
13var_dump(preg_replace_callback('//e', 'strtolower', ''));
14
15?>
16--EXPECTF--
17string(1) "x"
18string(4) "abcd"
19string(8) "zaab2k3l"
20
21Warning: preg_replace_callback(): Requires argument 2, '', to be a valid callback in %spreg_replace.php on line 8
22string(0) ""
23
24Warning: preg_replace_callback(): Modifier /e cannot be used with replacement callback in %spreg_replace.php on line 10
25NULL
26