-1

我如何为下面的“消息”实现 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.")
                );

但当然它会返回一个错误

4

1 回答 1

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

于 2013-10-02T19:32:37.290 回答