Php Htmlenties和json_encode,如果使用转义数据的json_encode,我是否需要使用Htmlenties?

Php Htmlenties和json_encode,如果使用转义数据的json_encode,我是否需要使用Htmlenties?,php,jquery,json,Php,Jquery,Json,Htmlenties和json_encode,如果使用转义数据的json_encode,我是否需要使用Htmlenties 这是否足够-json_编码转义数据 echo json_encode( $items ); 或者使用htmlentities转义数据: foreach ( $data as $d ) { $items[] = htmlentities( $d ); } echo json_encode( $items ); 客户端:

Htmlenties和json_encode,如果使用转义数据的json_encode,我是否需要使用Htmlenties

这是否足够-json_编码转义数据

    echo json_encode( $items );
或者使用htmlentities转义数据:

    foreach ( $data as $d ) {

        $items[] = htmlentities( $d );

    }

    echo json_encode( $items );
客户端:JQuery ajax:

    $('#textbox').attr( 'value', variable ); 

通常,您不需要使用
htmlentities()


我假设您正在ajax处理程序的上下文中使用它?如果是这样的话,您最大的担忧将是您的调用脚本到底期望得到什么。如果正确地处理JSON响应,那么除了
JSON\u encode()
之外,不需要做任何事情

为什么不使用一个抽象出这些关注点的框架呢?Symfony是一个不错的选择:我打算在将来使用和学习一个框架,但首先我需要学好php。