close

[Solved] PHP json encode – Malformed UTF-8 characters, possibly incorrectly encoded

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error PHP json encode – Malformed UTF-8 characters, possibly incorrectly encoded in php. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How PHP json encode – Malformed UTF-8 characters, possibly incorrectly encoded Error Occurs?

Today I get the following error PHP json encode – Malformed UTF-8 characters, possibly incorrectly encoded in php.

How To Solve PHP json encode – Malformed UTF-8 characters, possibly incorrectly encoded Error ?

  1. How To Solve PHP json encode – Malformed UTF-8 characters, possibly incorrectly encoded Error ?

    To Solve PHP json encode – Malformed UTF-8 characters, possibly incorrectly encoded Error you just add in your pdo connection charset=utf8 like below line of pdo connection:

  2. PHP json encode – Malformed UTF-8 characters, possibly incorrectly encoded

    To Solve PHP json encode – Malformed UTF-8 characters, possibly incorrectly encoded Error you just add in your pdo connection charset=utf8 like below line of pdo connection:

Solution 1


Remove HTML entities before JSON encoding. I used html_entity_decode() in PHP and the problem was solved

$json = html_entity_decode($source);
$data = json_decode($json,true);

Solution 2

you just add in your pdo connection charset=utf8 like below line of pdo connection:

$pdo = new PDO("mysql:host=localhost;dbname=mybase;charset=utf8", 'user', 'password');

hope this will help you

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment