Re: Why is ereg being deprecated?
| From: | Joey Smith | Date: | Mon, 12 Oct 2009 19:48:28 +0000 |
| Subject: | Re: Why is ereg being deprecated? | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-45788@lists.php.net to get a copy of this message | ||
Write yourself a bit of code that replaces ereg which could be installed in an
auto_prepend location server-wide. Here's an example you could start with,
although I should point out that I spent all of about 30 seconds thinking about
it, so you might want to give it more thought than that - I'm sure there are some
funny edge cases in the way people have relied on ereg behaviour, but you'd be
more likely to know that than I since I haven't used ereg() since the day PCRE
support was added to PHP.
if (! function_exists('ereg')) {
function ereg($pattern, $string, &$regs = array()) {
$matches = array();
$delimiters = array(chr(1),chr(1),chr(1),chr(1),chr(1),chr(1),'/', '@',
'#', '%', '_');
foreach($delimiters as $c) { if (strpos($string, $c) !== FALSE) continue; $d = $c; }
if (preg_match_all($d.$pattern.$d, $string, $matches)) return strlen($string);
return false;
}
}
Much the same could be done for split(), ereg_replace(), and so on.