Annotation of embedaddon/php/ext/pcre/tests/preg_quote_basic.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test preg_quote() function : basic functionality
3: --FILE--
4: <?php
5: /*
6: * proto string preg_quote(string str [, string delim_char])
7: * Function is implemented in ext/pcre/php_pcre.c
8: */
9: $string_before = '/this *-has \ metacharacters^ in $';
10: print "\$string_before looks like: $string_before\n"; //$string_before is printed as is written
11: $string_after = preg_quote($string_before, '/');
12: print "\$string_after looks like: $string_after, with metacharacters and / (set as delimiter) escaped\n"; //$string_after is printed with metacharacters escaped.
13: $string1 = 'testing - /this *-has \ metacharacters^ in $ should work';
14: var_dump(preg_match('/^[tT]\w{6} - ' . preg_quote($string_before, '/') . ' [a-z]*\s*work$/', $string1, $matches1));
15: var_dump($matches1);
16: ?>
17: --EXPECT--
18:
19: $string_before looks like: /this *-has \ metacharacters^ in $
20: $string_after looks like: \/this \*\-has \\ metacharacters\^ in \$, with metacharacters and / (set as delimiter) escaped
21: int(1)
22: array(1) {
23: [0]=>
24: string(58) "testing - /this *-has \ metacharacters^ in $ should work"
25: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>