Re: Why is ereg being deprecated?
| From: | Lukas Kahwe Smith | Date: | Mon, 12 Oct 2009 19:49:37 +0000 |
| Subject: | Re: Why is ereg being deprecated? | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-45789@lists.php.net to get a copy of this message | ||
On 12.10.2009, at 21:48, Joey Smith wrote:
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.Feel free to collaborate with the authors of PHP_Compat [1]. regards, Lukas Kahwe Smith mls@pooteeweet.org [1] http://pear.php.net/package/PHP_Compat