1--TEST-- 2Test 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 12echo "*** 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() */ 34echo "\n*** Output for strings ***\n"; 35foreach($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'' 55string(2) "''" 56 57 58-- Iteration: " " -- 59' ' 60' ' 61string(3) "' '" 62 63 64-- Iteration: '' -- 65'' 66'' 67string(2) "''" 68 69 70-- Iteration: ' ' -- 71' ' 72' ' 73string(3) "' '" 74 75 76-- Iteration: "string" -- 77'string' 78'string' 79string(8) "'string'" 80 81 82-- Iteration: 'string' -- 83'string' 84'string' 85string(8) "'string'" 86 87 88-- Iteration: "\0Hello\0 World\0" -- 89'' . "\0" . 'Hello' . "\0" . ' World' . "\0" . '' 90'' . "\0" . 'Hello' . "\0" . ' World' . "\0" . '' 91string(49) "'' . "\0" . 'Hello' . "\0" . ' World' . "\0" . ''" 92 93 94-- Iteration: "NULL" -- 95'NULL' 96'NULL' 97string(6) "'NULL'" 98 99 100-- Iteration: 'null' -- 101'null' 102'null' 103string(6) "'null'" 104 105 106-- Iteration: "FALSE" -- 107'FALSE' 108'FALSE' 109string(7) "'FALSE'" 110 111 112-- Iteration: 'false' -- 113'false' 114'false' 115string(7) "'false'" 116 117 118-- Iteration: "\x0b" -- 119'' 120'' 121string(3) "''" 122 123 124-- Iteration: "\0" -- 125'' . "\0" . '' 126'' . "\0" . '' 127string(14) "'' . "\0" . ''" 128 129 130-- Iteration: '\0' -- 131'\\0' 132'\\0' 133string(5) "'\\0'" 134 135 136-- Iteration: '\060' -- 137'\\060' 138'\\060' 139string(7) "'\\060'" 140 141 142-- Iteration: "\070" -- 143'8' 144'8' 145string(3) "'8'" 146 147===DONE=== 148