AI编程助手
AI免费问答

PHP 类的有关问题

  2016-06-13 10:24   1017浏览 原创

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');

php免费学习视频:立即学习
踏上前端学习之旅,开启通往精通之路!从前端基础到项目实战,循序渐进,一步一个脚印,迈向巅峰!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。