如何在php中设置类似mysql查询的utf8

时间:2017-01-15 09:14:33

标签: php mysql utf-8

您好我想在php中从mysql获取查询但不回显输出

当我在LIKE中使用英文单词时没问题,当我在phpmy中使用带有utf8字符的查询时,管理输出就可以了

请帮帮我

<?php
header('Content-Type: application/json');
$con=mysqli_connect("localhost","root","","ebrahim");
mysqli_set_charset($con,"utf8");
$sql="SELECT * FROM content WHERE writer LIKE 'شفق'";
    $result=mysqli_query($con,$sql);
    $response= array();
    while($row=mysqli_fetch_array($result,MYSQLI_NUM))
         {
         $product = array();
         $product["id"] = $row[0];
         $product["title"]=$row[1];
         $product["image"]="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png";
         $product["nim_body"]=$row[2];   
         $product["writer"]=$row[4]; 
         array_push($response,$product);
         }
echo json_encode($response,JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
?>

0 个答案:

没有答案