J'ai un problème avec readdir, si le fichier comporte un accent cela va m'afficher un losange avec un point d'interrogation; je suis obligé d'utiliser utf8_encode() pour rectifier cela. Alors j'aimerais bien comprendre ce qu'il se passe... Merci.
Code : Tout sélectionner
<?php
header('content-type:text/plain; charset=utf-8');
$dir = './';
if (is_dir($dir)):
if ($dh = opendir($dir)):
while (($file = readdir($dh)) !== false):
echo $file . "\n"; // problème d'accents
echo utf8_encode($file) . "\n"; // fonctionne correctement
endwhile;
endif;
endif;
closedir($dh);
?>