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.
8//$debug = true;
9ini_set('include_path', dirname(__FILE__));
10include_once('common.inc');
11
12// Set HTTP output encoding to ASCII
13$r = mb_http_output('ASCII');
14($r === TRUE) ? print "OK_ASCII_SET\n" : print "NG_ASCII_SET\n";
15$enc = mb_http_output();
16print "$enc\n";
17
18// Set HTTP output encoding to SJIS
19$r = mb_http_output('SJIS');
20($r === TRUE) ? print "OK_SJIS_SET\n" : print "NG_SJIS_SET\n";
21$enc = mb_http_output();
22print "$enc\n";
23
24// Set HTTP output encoding to JIS
25$r = mb_http_output('JIS');
26($r === TRUE) ? print "OK_JIS_SET\n" : print "NG_JIS_SET\n";
27$enc = mb_http_output();
28print "$enc\n";
29
30// Set HTTP output encoding to UTF8
31$r = mb_http_output('UTF-8');
32($r === TRUE) ? print "OK_UTF-8_SET\n" : print "NG_UTF-8_SET\n";
33$enc = mb_http_output();
34print "$enc\n";
35
36// Set HTTP output encoding to EUC-JP
37$r = mb_http_output('EUC-JP');
38($r === TRUE) ? print "OK_EUC-JP_SET\n" : print "NG_EUC-JP_SET\n";
39$enc = mb_http_output();
40print "$enc\n";
41
42// Invalid parameters
43print "== INVALID PARAMETER ==\n";
44
45// Note: Bad string raise Warning. Bad Type raise Notice (Type Conversion) and Warning....
46$r = mb_http_output('BAD_NAME');
47($r === FALSE) ? print "OK_BAD_SET\n" : print "NG_BAD_SET\n";
48$enc = mb_http_output();
49print "$enc\n";
50
51$r = mb_http_output($t_ary);
52($r === FALSE) ? print "OK_BAD_ARY_SET\n" : print "NG_BAD_ARY_SET\n";
53$enc = mb_http_output();
54print "$enc\n";
55
56$r = mb_http_output($t_obj);
57($r === FALSE) ? print "OK_BAD_OBJ_SET\n" : print "NG_BAD_OBJ_SET\n";
58$enc = mb_http_output();
59print "$enc\n";
60
61?>
62
63--EXPECT--
64OK_ASCII_SET
65ASCII
66OK_SJIS_SET
67SJIS
68OK_JIS_SET
69JIS
70OK_UTF-8_SET
71UTF-8
72OK_EUC-JP_SET
73EUC-JP
74== INVALID PARAMETER ==
75ERR: Warning
76OK_BAD_SET
77EUC-JP
78ERR: Warning
79OK_BAD_ARY_SET
80EUC-JP
81ERR: Warning
82OK_BAD_OBJ_SET
83EUC-JP
84
85