在PHP问题中显示Urdu

时间:2018-12-31 18:41:50

标签: php mysql utf-8

我试图在我的php基本api文件中显示urdu,但它显示出特殊字符。

根据其他论坛的参考资料,我已经使characterset = utf8和冲突,以下是php文件的url和代码。请指导我我在这里犯什么错误?

http://198.50.129.105/event_app_v2/get_question.php

     $conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}   


 $sql = "SELECT * FROM questions order by sequence";
    $result = $conn->query($sql);
    $data = [];
    //print_r($result);
    //exit;
    if ($result->num_rows > 0) {

        while($row = $result->fetch_assoc()) {
        $str='';
        $sql1 = "SELECT * FROM question_options where questionid=".$row["questionid"];
        $result1 = $conn->query($sql1);
        if ($result1->num_rows > 0) {
            while($row1 = $result1->fetch_assoc()) {
                $str.=$row1["options"].',';
            }
        }
            array_push($data,array(
                'questionid'=> $row["questionid"],
                'question'=> $row["question"],                
        'type'=> $row["type"],                
        'questiontype'=> $row["questiontype"],                
        'sequence'=> $row["sequence"],
        'questionnative'=>$row["questionnative"], 
        'options'=>rtrim($str,","),


                ));
        }
    } 
    if(count($data)){
         echo json_encode(['status'=>'true','data'=>$data]);
    }else{
         echo json_encode(['status'=>'true','data'=>[]]);
    }



$conn->close();
?>

0 个答案:

没有答案