2 Test var_export() function with locale
7 if (!setlocale(LC_ALL, "german", "de","de_DE","de_DE.ISO8859-1","de_DE.ISO_8859-1","de_DE.UTF-8")) {
8 die("skip locale needed for this test is not supported on this platform");
10 if (PHP_INT_SIZE < 8) {
11 die("skip 64-bit only");
16 setlocale(LC_ALL, "german", "de","de_DE","de_DE.ISO8859-1","de_DE.ISO_8859-1","de_DE.UTF-8");
17 /* Prototype: mixed var_export( mixed expression [, bool return]);
18 * Description: Returns the variable representation when the return parameter is used and evaluates to TRUE. Otherwise, this function will return NULL.
22 echo "*** Testing var_export() with integer values ***\n";
23 // different integer values
28 '-2147483648', // max negative integer value
30 2147483647, // max positive integer value
32 0x123B, // integer as hexadecimal
36 -0x7fffffff - 1, // max negative integer as hexadecimal
37 '0x7fffffff', // max positive integer as hexadecimal
38 0x7FFFFFFF, // max positive integer as hexadecimal
39 '0123', // integer as octal
40 01, // should be quivalent to octal 1
41 -017777777777 - 1, // max negative integer as octal
42 017777777777, // max positive integer as octal
45 /* Loop to check for above integer values with var_export() */
46 echo "\n*** Output for integer values ***\n";
47 foreach($valid_ints as $int_value) {
48 echo "\nIteration ".$counter."\n";
49 var_export( $int_value );
51 var_export( $int_value, FALSE);
53 var_dump( var_export( $int_value, TRUE) );
58 echo "*** Testing var_export() with valid boolean values ***\n";
59 // different valid boolean values
69 /* Loop to check for above boolean values with var_export() */
70 echo "\n*** Output for boolean values ***\n";
71 foreach($valid_bool as $bool_value) {
72 echo "\nIteration ".$counter."\n";
73 var_export( $bool_value );
75 var_export( $bool_value, FALSE);
77 var_dump( var_export( $bool_value, TRUE) );
82 echo "*** Testing var_export() with valid float values ***\n";
83 // different valid float values
84 $valid_floats = array(
85 (float)-2147483649, // float value
86 (float)2147483648, // float value
87 (float)-0x80000001, // float value, beyond max negative int
88 (float)0x800000001, // float value, beyond max positive int
89 (float)020000000001, // float value, beyond max positive int
90 (float)-020000000001, // float value, beyond max negative int
93 10.0000000000000000005,
107 /* Loop to check for above float values with var_export() */
108 echo "\n*** Output for float values ***\n";
109 foreach($valid_floats as $float_value) {
110 echo "\nIteration ".$counter."\n";
111 var_export( $float_value );
113 var_export( $float_value, FALSE);
115 var_dump( var_export( $float_value, TRUE) );
120 echo "*** Testing var_export() with valid strings ***\n";
121 // different valid string
122 $valid_strings = array(
140 /* Loop to check for above strings with var_export() */
141 echo "\n*** Output for strings ***\n";
142 foreach($valid_strings as $str) {
143 echo "\nIteration ".$counter."\n";
146 var_export( $str, FALSE);
148 var_dump( var_export( $str, TRUE) );
153 echo "*** Testing var_export() with valid arrays ***\n";
154 // different valid arrays
155 $valid_arrays = array(
162 array(array(), array()),
163 array(array(1, 2), array('a', 'b')),
165 array("test" => "is_array"),
169 array("string", "test"),
170 array('string', 'test')
173 /* Loop to check for above arrays with var_export() */
174 echo "\n*** Output for arrays ***\n";
175 foreach($valid_arrays as $arr) {
176 echo "\nIteration ".$counter."\n";
179 var_export( $arr, FALSE);
181 var_dump( var_export( $arr, TRUE) );
186 echo "*** Testing var_export() with valid objects ***\n";
188 // class with no members
195 abstract class abstractClass
197 abstract protected function getClassName();
198 public function printClassName () {
199 echo $this->getClassName() . "\n";
202 // implement abstract class
203 class concreteClass extends abstractClass
205 protected function getClassName() {
206 return "concreteClass";
213 public function setVal ($name, $val);
214 public function dumpVal ();
216 // implement the interface
217 class Value implements iValue
219 private $vars = array ();
221 public function setVal ( $name, $val ) {
222 $this->vars[$name] = $val;
225 public function dumpVal () {
226 var_export ( $vars );
236 private $private_var;
237 protected $protected_var;
239 function __construct ( ) {
240 $this->foo_object = new foo();
241 $this->public_var = 10;
242 $this->public_var1 = new foo();
243 $this->private_var = new foo();
244 $this->proected_var = new foo();
248 // create a object of each class defined above
249 $myClass_object = new myClass();
250 $foo_object = new foo();
251 $Value_object = new Value();
252 $concreteClass_object = new concreteClass();
254 $valid_objects = array(
261 $myClass_object->foo_object,
262 $myClass_object->public_var1,
265 $concreteClass_object
268 /* Loop to check for above objects with var_export() */
269 echo "\n*** Output for objects ***\n";
270 foreach($valid_objects as $obj) {
271 echo "\nIteration ".$counter."\n";
274 var_export( $obj, FALSE);
276 var_dump( var_export( $obj, TRUE) );
281 echo "*** Testing var_export() with valid null values ***\n";
282 // different valid null values
283 $unset_var = array();
284 unset ($unset_var); // now a null
287 $valid_nulls = array(
293 /* Loop to check for above null values with var_export() */
294 echo "\n*** Output for null values ***\n";
295 foreach($valid_nulls as $null_value) {
296 echo "\nIteration ".$counter."\n";
297 var_export( $null_value );
299 var_export( $null_value, FALSE);
301 var_dump( var_export( $null_value, true) );
311 *** Testing var_export() with integer values ***
313 *** Output for integer values ***
336 string(13) "'-2147483648'"
342 string(13) "'-2147483647'"
348 string(10) "2147483647"
354 string(10) "2147483640"
384 string(11) "-2147483648"
390 string(12) "'0x7fffffff'"
396 string(10) "2147483647"
414 string(11) "-2147483648"
420 string(10) "2147483647"
422 *** Testing var_export() with valid boolean values ***
424 *** Output for boolean values ***
461 *** Testing var_export() with valid float values ***
463 *** Output for float values ***
468 string(13) "-2147483649.0"
474 string(12) "2147483648.0"
480 string(13) "-2147483649.0"
486 string(13) "34359738369.0"
492 string(12) "2147483649.0"
498 string(13) "-2147483649.0"
510 string(20) "-0.10000000000000001"
522 string(9) "1050000.0"
532 1.0000000000000001E-5
533 1.0000000000000001E-5
534 string(21) "1.0000000000000001E-5"
556 1.0000000000000001E-5
557 1.0000000000000001E-5
558 string(21) "1.0000000000000001E-5"
564 string(9) "5000000.0"
568 6.0000000000000006E-20
569 6.0000000000000006E-20
570 string(22) "6.0000000000000006E-20"
574 5.0000000000000001E+42
575 5.0000000000000001E+42
576 string(22) "5.0000000000000001E+42"
580 3.4000000000000001E-33
581 3.4000000000000001E-33
582 string(22) "3.4000000000000001E-33"
584 *** Testing var_export() with valid strings ***
586 *** Output for strings ***
657 string(14) "'' . "\0" . ''"
677 *** Testing var_export() with valid arrays ***
679 *** Output for arrays ***
830 'test' => 'is_array',
833 'test' => 'is_array',
836 'test' => 'is_array',
867 1 => 5.5999999999999996,
871 1 => 5.5999999999999996,
875 1 => 5.5999999999999996,
908 *** Testing var_export() with valid objects ***
910 *** Output for objects ***
917 string(17) "(object) array(
922 foo::__set_state(array(
924 foo::__set_state(array(
926 string(26) "foo::__set_state(array(
931 concreteClass::__set_state(array(
933 concreteClass::__set_state(array(
935 string(36) "concreteClass::__set_state(array(
940 Value::__set_state(array(
945 Value::__set_state(array(
950 string(57) "Value::__set_state(array(
958 myClass::__set_state(array(
960 foo::__set_state(array(
964 foo::__set_state(array(
967 foo::__set_state(array(
969 'protected_var' => NULL,
971 foo::__set_state(array(
974 myClass::__set_state(array(
976 foo::__set_state(array(
980 foo::__set_state(array(
983 foo::__set_state(array(
985 'protected_var' => NULL,
987 foo::__set_state(array(
990 string(293) "myClass::__set_state(array(
992 foo::__set_state(array(
996 foo::__set_state(array(
999 foo::__set_state(array(
1001 'protected_var' => NULL,
1003 foo::__set_state(array(
1009 myClass::__set_state(array(
1011 foo::__set_state(array(
1015 foo::__set_state(array(
1018 foo::__set_state(array(
1020 'protected_var' => NULL,
1022 foo::__set_state(array(
1025 myClass::__set_state(array(
1027 foo::__set_state(array(
1031 foo::__set_state(array(
1034 foo::__set_state(array(
1036 'protected_var' => NULL,
1038 foo::__set_state(array(
1041 string(293) "myClass::__set_state(array(
1043 foo::__set_state(array(
1047 foo::__set_state(array(
1050 foo::__set_state(array(
1052 'protected_var' => NULL,
1054 foo::__set_state(array(
1060 foo::__set_state(array(
1062 foo::__set_state(array(
1064 string(26) "foo::__set_state(array(
1069 foo::__set_state(array(
1071 foo::__set_state(array(
1073 string(26) "foo::__set_state(array(
1078 foo::__set_state(array(
1080 foo::__set_state(array(
1082 string(26) "foo::__set_state(array(
1087 Value::__set_state(array(
1092 Value::__set_state(array(
1097 string(57) "Value::__set_state(array(
1105 concreteClass::__set_state(array(
1107 concreteClass::__set_state(array(
1109 string(36) "concreteClass::__set_state(array(
1112 *** Testing var_export() with valid null values ***
1114 *** Output for null values ***