1--TEST-- 2Test setlocale() function : usage variations - Setting system locale as empty string 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) == 'WIN') { 6 die('skip Not valid for windows'); 7} 8if (setlocale(LC_ALL,'en_AU.utf8') === false || setlocale(LC_ALL,'en_US.utf8') === false) { 9 die('skip en_AU.utf8/en_US.utf8 locales not available'); 10} 11?> 12--ENV-- 13LC_ALL=en_US.utf8; 14--FILE-- 15<?php 16/* If locale is empty string "", the locale names will be set from the values of environment variables with the same names as from ENV */ 17 18echo "*** Testing setlocale() : usage variations - setting system locale = \"\" ***\n"; 19 20//initially setting the locale 21setlocale(LC_ALL,'en_AU.utf8'); 22 23echo "Locale info, before setting the locale\n"; 24 25//returns current locale,before executing setlocale() . 26$locale_info_before = localeconv(); 27 28var_dump($locale_info_before); 29 30//Testing setlocale() by giving locale = null 31echo "Setting system locale, category = LC_ALL and locale = \"\"\n"; 32setlocale(LC_ALL, ""); 33 34echo "Locale info, after setting the locale\n"; 35 36//Returns Current locale,after executing setlocale(). 37$locale_info_after = localeconv(); 38 39var_dump($locale_info_after); 40 41echo "Checking new locale in the system, Expected : the locale names will be set from the values of environment variables\n"; 42echo "Test "; 43if($locale_info_before != $locale_info_after){ 44 echo "PASSED."; 45} else { 46 echo "FAILED."; 47} 48 49echo "\nDone\n"; 50?> 51--EXPECT-- 52*** Testing setlocale() : usage variations - setting system locale = "" *** 53Locale info, before setting the locale 54array(18) { 55 ["decimal_point"]=> 56 string(1) "." 57 ["thousands_sep"]=> 58 string(1) "," 59 ["int_curr_symbol"]=> 60 string(4) "AUD " 61 ["currency_symbol"]=> 62 string(1) "$" 63 ["mon_decimal_point"]=> 64 string(1) "." 65 ["mon_thousands_sep"]=> 66 string(1) "," 67 ["positive_sign"]=> 68 string(0) "" 69 ["negative_sign"]=> 70 string(1) "-" 71 ["int_frac_digits"]=> 72 int(2) 73 ["frac_digits"]=> 74 int(2) 75 ["p_cs_precedes"]=> 76 int(1) 77 ["p_sep_by_space"]=> 78 int(0) 79 ["n_cs_precedes"]=> 80 int(1) 81 ["n_sep_by_space"]=> 82 int(0) 83 ["p_sign_posn"]=> 84 int(1) 85 ["n_sign_posn"]=> 86 int(1) 87 ["grouping"]=> 88 array(2) { 89 [0]=> 90 int(3) 91 [1]=> 92 int(3) 93 } 94 ["mon_grouping"]=> 95 array(2) { 96 [0]=> 97 int(3) 98 [1]=> 99 int(3) 100 } 101} 102Setting system locale, category = LC_ALL and locale = "" 103Locale info, after setting the locale 104array(18) { 105 ["decimal_point"]=> 106 string(1) "." 107 ["thousands_sep"]=> 108 string(1) "," 109 ["int_curr_symbol"]=> 110 string(4) "USD " 111 ["currency_symbol"]=> 112 string(1) "$" 113 ["mon_decimal_point"]=> 114 string(1) "." 115 ["mon_thousands_sep"]=> 116 string(1) "," 117 ["positive_sign"]=> 118 string(0) "" 119 ["negative_sign"]=> 120 string(1) "-" 121 ["int_frac_digits"]=> 122 int(2) 123 ["frac_digits"]=> 124 int(2) 125 ["p_cs_precedes"]=> 126 int(1) 127 ["p_sep_by_space"]=> 128 int(0) 129 ["n_cs_precedes"]=> 130 int(1) 131 ["n_sep_by_space"]=> 132 int(0) 133 ["p_sign_posn"]=> 134 int(1) 135 ["n_sign_posn"]=> 136 int(1) 137 ["grouping"]=> 138 array(2) { 139 [0]=> 140 int(3) 141 [1]=> 142 int(3) 143 } 144 ["mon_grouping"]=> 145 array(2) { 146 [0]=> 147 int(3) 148 [1]=> 149 int(3) 150 } 151} 152Checking new locale in the system, Expected : the locale names will be set from the values of environment variables 153Test PASSED. 154Done 155