Ver Mensaje Individual
  #7 (permalink)  
Antiguo 09/03/2011, 12:10
cambalachito
 
Fecha de Ingreso: febrero-2009
Mensajes: 56
Antigüedad: 16 años
Puntos: 3
Respuesta: CUál es mejor usar ???

Gracias DeeR !!!

Hago mi corrección en el código..... PREG_MATCH Gana !!!


Código PHP:
<?php
$email 
"[email protected]";
$patron "/^\S+@[\w\d.-]{2,}\.[\w]{2,6}$/iU";
$tiempo_inicial_filtro microtime(true);

    if(
filter_var($emailFILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>$patron))) == true)
    {
        
$tiempo_filtro microtime(true) - $tiempo_inicial_filtro;
        echo 
number_format($tiempo_filtro6'.''').' > Utilizando FILTER_VAR<br><br>';
    }

$tiempo_inicial_preg_match microtime(true);

    if (
preg_match($patron$email) == true)
    {
        
$tiempo_preg_match microtime(true) - $tiempo_inicial_preg_match;
        echo 
number_format($tiempo_preg_match6'.''').' > Utilizando PREG_MATCH<br><br><br>';
    }
    
    echo 
'<strong>Conclusion</strong>: Utilizando PREG_MATCH se validan las Expresiones Regulares m&aacute;s R&aacute;pido !!';
?>
Me imagino que al ser Preg_Match una funcion dirigida a las REGEX es más rapida, mientras que en Filter_var hay una mayor interpretacion del servidor !!

Gracias !