Annotation of embedaddon/php/ext/standard/tests/general_functions/var_export_basic4.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test var_export() function with valid strings
3: --FILE--
4: <?php
5: /* Prototype : mixed var_export(mixed var [, bool return])
6: * Description: Outputs or returns a string representation of a variable
7: * Source code: ext/standard/var.c
8: * Alias to functions:
9: */
10:
11:
12: echo "*** Testing var_export() with valid strings ***\n";
13: // different valid string
14: $valid_strings = array(
15: "\"\"" => "",
16: "\" \"" => " ",
17: "''" => '',
18: "' '" => ' ',
19: "\"string\"" => "string",
20: "'string'" => 'string',
21: "\"\\0Hello\\0 World\\0\"" => "\0Hello\0 World\0",
22: "\"NULL\"" => "NULL",
23: "'null'" => 'null',
24: "\"FALSE\"" => "FALSE",
25: "'false'" => 'false',
26: "\"\\x0b\"" => "\x0b",
27: "\"\\0\"" => "\0",
28: "'\\0'" => '\0',
29: "'\\060'" => '\060',
30: "\"\\070\"" => "\070"
31: );
32:
33: /* Loop to check for above strings with var_export() */
34: echo "\n*** Output for strings ***\n";
35: foreach($valid_strings as $key => $str) {
36: echo "\n-- Iteration: $key --\n";
37: var_export( $str );
38: echo "\n";
39: var_export( $str, FALSE);
40: echo "\n";
41: var_dump( var_export( $str, TRUE) );
42: echo "\n";
43: }
44:
45: ?>
46: ===DONE===
47: --EXPECT--
48: *** Testing var_export() with valid strings ***
49:
50: *** Output for strings ***
51:
52: -- Iteration: "" --
53: ''
54: ''
55: string(2) "''"
56:
57:
58: -- Iteration: " " --
59: ' '
60: ' '
61: string(3) "' '"
62:
63:
64: -- Iteration: '' --
65: ''
66: ''
67: string(2) "''"
68:
69:
70: -- Iteration: ' ' --
71: ' '
72: ' '
73: string(3) "' '"
74:
75:
76: -- Iteration: "string" --
77: 'string'
78: 'string'
79: string(8) "'string'"
80:
81:
82: -- Iteration: 'string' --
83: 'string'
84: 'string'
85: string(8) "'string'"
86:
87:
88: -- Iteration: "\0Hello\0 World\0" --
89: '' . "\0" . 'Hello' . "\0" . ' World' . "\0" . ''
90: '' . "\0" . 'Hello' . "\0" . ' World' . "\0" . ''
91: string(49) "'' . "\0" . 'Hello' . "\0" . ' World' . "\0" . ''"
92:
93:
94: -- Iteration: "NULL" --
95: 'NULL'
96: 'NULL'
97: string(6) "'NULL'"
98:
99:
100: -- Iteration: 'null' --
101: 'null'
102: 'null'
103: string(6) "'null'"
104:
105:
106: -- Iteration: "FALSE" --
107: 'FALSE'
108: 'FALSE'
109: string(7) "'FALSE'"
110:
111:
112: -- Iteration: 'false' --
113: 'false'
114: 'false'
115: string(7) "'false'"
116:
117:
118: -- Iteration: "\x0b" --
119: ''
120: ''
121: string(3) "''"
122:
123:
124: -- Iteration: "\0" --
125: '' . "\0" . ''
126: '' . "\0" . ''
127: string(14) "'' . "\0" . ''"
128:
129:
130: -- Iteration: '\0' --
131: '\\0'
132: '\\0'
133: string(5) "'\\0'"
134:
135:
136: -- Iteration: '\060' --
137: '\\060'
138: '\\060'
139: string(7) "'\\060'"
140:
141:
142: -- Iteration: "\070" --
143: '8'
144: '8'
145: string(3) "'8'"
146:
147: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>