1--TEST-- 2mb_http_output() 3--SKIPIF-- 4<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> 5--FILE-- 6<?php 7//TODO: Add more encoding. Wrong parameter type test. 8ini_set('include_path', __DIR__); 9include_once('common.inc'); 10 11// Set HTTP output encoding to ASCII 12$r = mb_http_output('ASCII'); 13($r === TRUE) ? print "OK_ASCII_SET\n" : print "NG_ASCII_SET\n"; 14$enc = mb_http_output(); 15print "$enc\n"; 16 17// Set HTTP output encoding to SJIS 18$r = mb_http_output('SJIS'); 19($r === TRUE) ? print "OK_SJIS_SET\n" : print "NG_SJIS_SET\n"; 20$enc = mb_http_output(); 21print "$enc\n"; 22 23// Set HTTP output encoding to JIS 24$r = mb_http_output('JIS'); 25($r === TRUE) ? print "OK_JIS_SET\n" : print "NG_JIS_SET\n"; 26$enc = mb_http_output(); 27print "$enc\n"; 28 29// Set HTTP output encoding to UTF8 30$r = mb_http_output('UTF-8'); 31($r === TRUE) ? print "OK_UTF-8_SET\n" : print "NG_UTF-8_SET\n"; 32$enc = mb_http_output(); 33print "$enc\n"; 34 35// Set HTTP output encoding to EUC-JP 36$r = mb_http_output('EUC-JP'); 37($r === TRUE) ? print "OK_EUC-JP_SET\n" : print "NG_EUC-JP_SET\n"; 38$enc = mb_http_output(); 39print "$enc\n"; 40 41// Invalid parameters 42print "== INVALID PARAMETER ==\n"; 43 44// Note: Bad string raise Warning. Bad Type raise Notice (Type Conversion) and Warning.... 45$r = mb_http_output('BAD_NAME'); 46($r === FALSE) ? print "OK_BAD_SET\n" : print "NG_BAD_SET\n"; 47$enc = mb_http_output(); 48print "$enc\n"; 49 50$r = mb_http_output($t_ary); 51($r === NULL) ? print "OK_BAD_ARY_SET\n" : print "NG_BAD_ARY_SET\n"; 52$enc = mb_http_output(); 53print "$enc\n"; 54 55$r = mb_http_output($t_obj); 56($r === NULL) ? print "OK_BAD_OBJ_SET\n" : print "NG_BAD_OBJ_SET\n"; 57$enc = mb_http_output(); 58print "$enc\n"; 59 60?> 61--EXPECTF-- 62OK_ASCII_SET 63ASCII 64OK_SJIS_SET 65SJIS 66OK_JIS_SET 67JIS 68OK_UTF-8_SET 69UTF-8 70OK_EUC-JP_SET 71EUC-JP 72== INVALID PARAMETER == 73 74Warning: mb_http_output(): Unknown encoding "BAD_NAME" in %s on line %d 75OK_BAD_SET 76EUC-JP 77 78Warning: mb_http_output() expects parameter 1 to be string, array given in %s on line %d 79OK_BAD_ARY_SET 80EUC-JP 81 82Warning: mb_http_output() expects parameter 1 to be string, object given in %s on line %d 83OK_BAD_OBJ_SET 84EUC-JP 85