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 === NULL) ? 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 === NULL) ? print "OK_BAD_OBJ_SET\n" : print "NG_BAD_OBJ_SET\n";
58$enc = mb_http_output();
59print "$enc\n";
60
61?>
62--EXPECT--
63OK_ASCII_SET
64ASCII
65OK_SJIS_SET
66SJIS
67OK_JIS_SET
68JIS
69OK_UTF-8_SET
70UTF-8
71OK_EUC-JP_SET
72EUC-JP
73== INVALID PARAMETER ==
74ERR: Warning
75OK_BAD_SET
76EUC-JP
77ERR: Warning
78OK_BAD_ARY_SET
79EUC-JP
80ERR: Warning
81OK_BAD_OBJ_SET
82EUC-JP
83