如何为下面的'message'实现gettext echo _(“”)?
$output = array(
'returnCode' => '0',
'message' => "Sorry, an error has occured. Please try again."
);
echo json_encode($output);
我试过
$output = array(
'returnCode' => '0',
'message' => echo _("Sorry, an error has occured. Please try again.")
);
但当然会返回错误
答案 0 :(得分:0)
如果您只想回复索引message
,您可以这样做:
$output = array(
'returnCode' => '0',
'message' => "Sorry, an error has occured. Please try again."
);
$message = $output['message'];
echo $message; //output: Sorry, an error has occured. Please try again.
以json格式回显:
echo json_encode($message);
取决于你将做什么你应该在编码为json之前对变量做utf8_encode