On Mon, 12 Oct 2009, jval...@eoni.com wrote:
Mark Krenz wrote:

7. PHP Cookbook from 2006
Has mixed examples, some using ereg and some using preg_match

In PHP Cookbook, the only use of ereg I found was in the section
where the books was explaining how to convert from ereg to
preg_match. Or an occasional mention that said you could do it with
ereg but preg_match was better. But, I might have missed something.

No. You are correct. We switched over all the examples to preg when we
revised the book for the second edition.

As we said in the introduction to our Regular Expressions chapter: "In
general, there's no longer any reason to use the ereg functions."

We also included a Recipe for converting from ereg to preg, including
how to use addcslashes() to escape your delimiter, and dechex() when
you're using an integer instead of a string as an input value for a
pattern or replacement (a valid, and highly useful case in some
instances, but very esoteric for most programs).

So, yes, there is some work that needs to be done to upgrade scripts,
and, yes, there are some dank corner cases, but they are relatively
straight forward to go after, shed light on, and clean up.

As someone who had to convert legacy code from PHP/FI to PHP 3, when
PHP changed its string contactenation operator, of all things, I can
say that subbing ereg() for preg() is an easier transition, especially
when it has the value of letting PHP 6 seamlessly support Unicode.

-adam

--
a...@trachtenberg.com | http://www.trachtenberg.com
author of o'reilly's "upgrading to php 5" and "php cookbook"
avoid the holiday rush, buy your copies today!

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to