1--TEST-- 2mb_detect_order() 3--EXTENSIONS-- 4mbstring 5--INI-- 6mbstring.language=Japanese 7--FILE-- 8<?php 9//$debug = true; 10ini_set('include_path', __DIR__); 11include_once('common.inc'); 12 13 14// Set order to "auto" 15$r = mb_detect_order('auto'); 16($r === TRUE) ? print "OK_AUTO\n" : print "NG_AUTO\n"; 17print implode(', ', mb_detect_order()) . "\n"; 18 19 20// Set order by string 21$r = mb_detect_order('SJIS,EUC-JP,JIS,UTF-8'); 22($r === TRUE) ? print "OK_STR\n" : print "NG_STR\n"; 23print implode(', ', mb_detect_order()) . "\n"; 24 25 26// Set order by array 27$a[] = 'ASCII'; 28$a[] = 'JIS'; 29$a[] = 'EUC-JP'; 30$a[] = 'UTF-8'; 31$r = mb_detect_order($a); 32($r === TRUE) ? print "OK_ARRAY\n" : print "NG_ARRAY\n"; 33print implode(', ', mb_detect_order()) . "\n"; 34 35// Set invalid encoding. Should fail. 36print "== INVALID PARAMETER ==\n"; 37 38try { 39 var_dump(mb_detect_order('BAD_NAME')); 40} catch (\ValueError $e) { 41 echo $e->getMessage() . \PHP_EOL; 42} 43var_dump(mb_detect_order()); 44 45$a[] = 'BAD_NAME'; 46try { 47 var_dump(mb_detect_order($a)); 48} catch (\ValueError $e) { 49 echo $e->getMessage() . \PHP_EOL; 50} 51var_dump(mb_detect_order()); 52 53?> 54--EXPECT-- 55OK_AUTO 56ASCII, JIS, UTF-8, EUC-JP, SJIS 57OK_STR 58SJIS, EUC-JP, JIS, UTF-8 59OK_ARRAY 60ASCII, JIS, EUC-JP, UTF-8 61== INVALID PARAMETER == 62mb_detect_order(): Argument #1 ($encoding) contains invalid encoding "BAD_NAME" 63array(4) { 64 [0]=> 65 string(5) "ASCII" 66 [1]=> 67 string(3) "JIS" 68 [2]=> 69 string(6) "EUC-JP" 70 [3]=> 71 string(5) "UTF-8" 72} 73mb_detect_order(): Argument #1 ($encoding) contains invalid encoding "BAD_NAME" 74array(4) { 75 [0]=> 76 string(5) "ASCII" 77 [1]=> 78 string(3) "JIS" 79 [2]=> 80 string(6) "EUC-JP" 81 [3]=> 82 string(5) "UTF-8" 83} 84