you shoud adjust 2 sides
one side in your code by setting connection charset
by execute these queries after connection start with your db
header("Content-type:application/json;charset=utf8_general_ci");
require_once('db.php');
$sql = 'SET NAMES "UTF8"';
$stm = $db->prepare($sql);
$stm->execute();
$sql = 'SET CHARACTER SET utf8' ;
$stm = $db->prepare($sql);
$stm->execute()
$sql = "SET COLLATION_CONNECTION = 'utf8_unicode_ci'" ;
$stm = $db->prepare($sql) ;
$stm->execute()
$query = 'SELECT * FROM `hebreux`';
$stm = $db->prepare($query);
$stm->execute();
$rows = $stm->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($rows);
then your files where you write your code open with any program like Notepad++ that allow you to adjust file Encoding then change all files to UTF-8-BOM
You can adjust database by any way like
If you're using the PDO abstraction layer with PHP ≥ 5.3.6, you can specify charset in the DSN:
$dbh = new PDO('mysql:charset=utf8mb4');
If you're using mysqli, you can call set_charset():
$mysqli->set_charset('utf8mb4'); // object oriented style
mysqli_set_charset($link, 'utf8mb4'); // procedural style
If you're stuck with plain mysql but happen to be running PHP ≥ 5.2.3, you can call mysql_set_charset.
If the driver does not provide its own mechanism for setting the connection character set, you may have to issue a query to tell MySQL how your application expects data on the connection to be encoded: SET NAMES 'utf8mb4'.