Eso es porque strtolower no soporta cadenas unicode (UTF8) por eso se recomienda el uso de mb_strtolower, por ejemplo este script sencillo, codificado como ANSI:
Código PHP:
Ver original<?php
header('Content-type: text/html; charset=iso-8859-1'); $str = setlocale(LC_ALL
, 'es_MX', 'esp_mex'); ?>
<html>
<head>
<meta name="Content-type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
$str = 'EsTOEsUÑAPruebaAcentosÁÉÍÓÚ';
echo "Original: $str<br />";
echo 'LowerCased: ' . strtolower($str) . '<br />'; ?>
</body>
</html>
Funciona correctamente ej:
Cita: Original: EsTOEsUÑAPruebaAcentosÁÉÍÓÚ
LowerCased: estoesuñapruebaacentosáéíóú
Sin embargo si lo haces en un script codificado como UTF-8:
Código PHP:
Ver original<?php
header('Content-type: text/html; charset=utf-8'); $str = setlocale(LC_ALL
, 'es_MX', 'esp_mex'); ?>
<html>
<head>
<meta name="Content-type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php
$str = 'EsTOEsUÑAPruebaAcentosÁÉÍÓÚ';
echo "Original: $str<br />";
echo 'LowerCased: ' . strtolower($str) . '<br />'; ?>
</body>
</html>
La salida:
Cita: Original: EsTOEsUÑAPruebaAcentosÁÉÍÓÚ
LowerCased: estoesu�apruebaacentos�����
LowerCased: estoesuñapruebaacentosáéíóú
¿Solución? Decide bien que juego de carácteres vas a ocupar, por ejemplo, si va a ser UTF-8 checa que tengas todo el soporte, de lo contrario regresa a iso-8859-1, y asegurate que todo, tus archivos, documentos html y bdd se comuniquen con el mismo charset.
Saludos.