国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

php - About redis read and write escape
迷茫
迷茫 2017-07-03 11:40:42
0
2
1603

I only came into contact with redis and related things because of work needs. The result is as follows:
Part of the code is as follows
$newsRedis = Redis::get('news_'.$id);

    if ($newsRedis) return $newsRedis;
    $re = NewNotice::select('community', 'title', 'created_at', 'content', 'initiator', 'img')->where('id', '=', $id)->get();

    $change = NewNotice::where('id', '=', $id)->update([
        'state' => '1'
    ]);
    if (!$change) return 'NOTICE_ERROR';

// dd($change);

    Redis::set('news_'.$id,$re);
    Redis::expire('news_'.$id,10);
    return $re;
}

It turned out that there was an escape slash before each symbol

The following is the result of my direct return $re

Why does this happen? How can I avoid escaping?

迷茫
迷茫

業(yè)精于勤,荒于嬉;行成于思,毀于隨。

reply all(2)
漂亮男人

You take it out, first json_decode and then encapsulate the data and output it to the front end.
Your escaping is because it was json_encode twice.

What you store in Redis is a JSON string. You take it out directly, put it into the data, and perform json_encode again, so it is normal for this to happen.

淡淡煙草味

This escaping is normal. It’s because of json. JSON requires that all key values ??must be enclosed in double quotes ". Values ??containing double quotes naturally need to be escaped. You dd($change->datas) will not have slashes If you really don’t want to see the double quotes, you can url_encode first and then url_decode when using it, but it’s not necessary

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template