i want to insert value through Json_encode through controller but json_encode() not working in yii2.
json_encode();
i want to insert value through Json_encode through controller but json_encode() not working in yii2.
json_encode();
You can test json_encode()
in a controller:
public function actionIndex()
{
$json = json_encode(['key'=>'value']);
echo $json;
}
The result should be:
{"key":"value"}
json_encode()
won't be unworked without an error such as no php-json
extension, and it is a PHP function which works the same in Yii2.