cvs: pear /Validate Validate.php

From: Date: Wed, 29 May 2002 08:20:24 +0000
Subject: cvs: pear /Validate Validate.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-4234@lists.php.net to get a copy of this message
cox Wed May 29 04:20:24 2002 EDT Modified files: /pear/Validate Validate.php Log: Use faster preg_match instead of ereg # <?php # $a="http://foo.bar"; # $t = time(); # for ($i=0; $i<1000000;$i++) # eregi('^http$', $a); # echo "eregi: " . (time() - $t) . "s\n"; # $t = time(); # for ($i=0; $i<1000000;$i++) # preg_match('|^http$|i', $a); # echo "preg: " . (time() - $t) . "s\n"; # ?> # Output: # eregi: 12s # preg: 5s Index: pear/Validate/Validate.php diff -u pear/Validate/Validate.php:1.4 pear/Validate/Validate.php:1.5 --- pear/Validate/Validate.php:1.4 Wed May 29 03:50:52 2002 +++ pear/Validate/Validate.php Wed May 29 04:20:24 2002 @@ -24,7 +24,7 @@ { $dec_prec = $dec_prec ? "{1,$dec_prec}" : '+'; $dec_regex = $decimal ? $decimal . '[0-9]' . $dec_prec : ''; - if (!ereg("^[0-9]+($dec_regex)?\$", $number)) { + if (!preg_match("|^[0-9]+($dec_regex)?\$|", $number)) { return false; } if ($decimal != '.') { @@ -86,7 +86,7 @@ function url($url, $domain_check = false) { $purl = parse_url($url); - if (eregi('^http$', @$purl['scheme']) && !empty($purl['host'])) { + if (preg_match('|^http$|i', @$purl['scheme']) && !empty($purl['host'])) { if ($domain_check && function_exists('checkdnsrr')) { if (checkdnsrr($purl['host'], 'A')) { return true;

« previous php.pear.cvs (#4234) next »