php with special characters like ñ

后端 未结 6 773
傲寒
傲寒 2021-02-06 09:50

At first I thought the problem was when I return echo json_encode($row) from an ajax call that results with ñ are changed to NULL. But after testing I found out that the problem

6条回答
  •  没有蜡笔的小新
    2021-02-06 10:26

    for me

    $test = "Nuñez";
    echo $test;
    

    shows Nuñez

    You may try

    $test = "Nuñez";
    echo utf8_decode($test);
    

    or

    $test = utf8_encode("Nuñez");
    echo utf8_decode($test);
    

提交回复
热议问题