未在codeigniter中定义常量JSON_UNESCAPED_UNICODE [英] undefined constant JSON_UNESCAPED_UNICODE in codeigniter
本文介绍了未在codeigniter中定义常量JSON_UNESCAPED_UNICODE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建一个Json文件
I create a Json file
$json = array(
"Add"=>array(
"context" => "$context",
"date"=> "$date"
),
"Version"=>array(
"version"=>$version
)
);
$context
是波斯文字(所以我的Json需要UTF-8格式).现在我用这个
And $context
is a persian text(so i need a UTF-8 format for my Json) . Now i use this
echo json_encode($json,JSON_UNESCAPED_UNICODE);
查看我的json文件,但Codeigniter给出了这两个错误
to see my json file ,but Codeigniter gives these 2 errors
A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant JSON_UNESCAPED_UNICODE - assumed 'JSON_UNESCAPED_UNICODE'
和
A PHP Error was encountered
Severity: Warning
Message: json_encode() expects parameter 2 to be long, string given
有什么想法吗?谢谢.
推荐答案
来自文档:
JSON_UNESCAPED_UNICODE(整数)
[...]自PHP 5.4.0起可用.
JSON_UNESCAPED_UNICODE (integer)
[...] Available since PHP 5.4.0.
您的PHP版本没有定义的常量(并且定义常量将无济于事).
Your version of PHP does not have the constant defined (and defining it won't help).
这篇关于未在codeigniter中定义常量JSON_UNESCAPED_UNICODE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文