
09/03/2011, 11:16
|
| | Fecha de Ingreso: febrero-2009
Mensajes: 56
Antigüedad: 16 años Puntos: 3 | |
Respuesta: CUál es mejor usar ??? Resultados: (Hice un pequeño Script para probar)
Lo comparto  !! Código PHP: <?php
$email = "[email protected]";
$patron = "/^\S+@[\w\d.-]{2,}\.[\w]{2,6}$/iU";
$tiempo_inicial = microtime(true);
if(filter_var($email, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>$patron))) == true)
{
$tiempo_filtro = microtime(true) - $tiempo_inicial;
echo number_format($tiempo_filtro, 6, '.', '').' > Utilizando FILTER_VAR<br><br>';
}
if (preg_match($patron, $email) == true)
{
$tiempo_preg_match = microtime(true) - $tiempo_inicial;
echo number_format($tiempo_preg_match, 6, '.', '').' > Utilizando PREG_MATCH<br><br><br>';
}
echo '<strong>Conclusion</strong>: Utilizando FILTER VAR se validan las Expresiones Regulares más Rápido !!';
?> Filter_var es el Ganador !!! |