Home >Backend Development >PHP Tutorial >PHP 类的有关问题

PHP 类的有关问题

WBOY
WBOYOriginal
2016-06-13 10:24:56892browse

PHP 类的问题
调用源码

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$obj_car = new class_car;$num_carId = $obj_car->fn_carAdd($_POST);



类源码
PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->class class_car {    function fn_carAdd($arr_post) {        print_r($arr_post);    }}


这样可以正常输出数组
PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->Array(    [action_post] => carAdd    [str_postChk] =>     [str_carName] => 高尔夫    [num_carBrand] => 7    [num_carModel] => 615    [str_carEmiss] => 1.4T    [str_carTrans] => MT)



类源码
PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->class class_car {    function fn_carAdd($arr_post) {        print_r($arr_post["str_carName"]);    }}


这样输出乱码,求解,文件本身编码都没问题

------解决方案--------------------
header发送编码。
加在程序开始就行了。

header('Content-Type:text/html; charset=utf-8');
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn