0

javascriptイベントでHTMLページにテキストを配置するために使用されるrun.phpとclass/functions.phpの2つのファイルがあります(そのためにAJAXが使用されます)。

run.php ファイルは次のとおりです。

<?php
mb_internal_encoding("UTF-8");

require_once('class/functions.php');

$text = array();
$text[0]="rrrrrr";

strange_func($text, 0);//puts "фа" into $text[0]
$res1=$text[0];

$arr = array();

$arr['res1'] = $res1;
$arr['res2'] = "test";

header('Content-type: application/json');
echo json_encode($arr);
?>

class/functions.php には以下が含まれます:

function strange_func(&$text, $i){
    $text[$i]="hello123";//hello123 will be displayed on html page on javascript event
    //$text[$i]="фь";
    //if we comment hello123 and uncomment фь, then фь will NOT be displayed on the html page on javascript event by unknown reason. Why?
}

さらに、私require_once('class/functions.php');

function strange_func(&$text, $i){
    $text[$i]="фь";
}

の場合、「фь」が表示されます。strange_funcでは、テキストがキリル文字の場合、関数fromclass/functions.phpがテキストを表示しないのはなぜでしょうか?

上記のコードは単純化した結果であり、あまり意味がありません。しかし、問題はまだ存在します。

4

1 に答える 1

1

utf-8 エンコードで保存 (BOM なし)

于 2012-04-24T20:54:31.140 に答える