4

私のサイトでは、ユーザーがアラビア語/英語の名前で登録できるようになっています

ユーザーの名前と姓を小文字に変換しようとしています

私はこの機能を使用しています

$first_name = strtolower ( $_POST['first_name'] );

アラビア語の名前を付けようとすると、このエンコードが表示されます(ø¹ù„ø§ø¡)

自分で試してみてください

<?
echo 'مصر'; // return مصر
echo strtolower('مصر'); // return ø¹ù„ø§ø¡
?>

?>

4

1 に答える 1

11

You can't use strtolower on UTF-8 encoded string, only on ISO 8859-1. Use mb_strtolower() instead. You also need to specify the encoding used, make sure it's set correctly (probably "UTF-8").

<?
echo 'مصر'; // return مصر
echo mb_strtolower('مصر', 'UTF-8'); // return مصر
?>
于 2012-05-17T16:29:18.413 に答える