Annotation of embedaddon/php/ext/standard/tests/strings/addslashes_basic.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test addslashes() function : basic functionality
3: --FILE--
4: <?php
5: /* Prototype : string addslashes ( string $str )
6: * Description: Returns a string with backslashes before characters (single quotes, double quote,
7: * backslash and nul character) that need to be quoted in database queries etc.
8: * Source code: ext/standard/string.c
9: */
10:
11: /*
12: * Testing addslashes() with strings containing characters that can be prefixed with backslash
13: * by the function
14: */
15:
16: echo "*** Testing addslashes() : basic functionality ***\n";
17:
18: // Initialize all required variables
19: $str_array = array( "How's everybody", // string containing single quote
20: 'Are you "JOHN"?', // string with double quotes
21: 'c:\php\addslashes', // string with backslashes
22: "hello\0world" // string with nul character
23: );
24:
25: // Calling addslashes() with all arguments
26: foreach( $str_array as $str ) {
27: var_dump( addslashes($str) );
28: }
29:
30: echo "Done\n";
31: ?>
32: --EXPECTF--
33: *** Testing addslashes() : basic functionality ***
34: string(16) "How\'s everybody"
35: string(17) "Are you \"JOHN\"?"
36: string(19) "c:\\php\\addslashes"
37: string(12) "hello\0world"
38: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>