FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Eregi possible problem
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Eregi possible problem [message #169355 is a reply to message #169353] Wed, 08 September 2010 09:04 Go to previous messageGo to previous message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma:
Senior Member
El 08/09/2010 10:02, GarryJones escribió/wrote:
> To fix another problem I turned errors reporting on (I normally have
> it off so users dont see errors that are not a problem).
>
> I then received a surprising message about another line of code that
> has worked for years. It says that eregi is depreciated, I am unsure
> what that means as my code was still working so its strange that this
> error came up as it is not an actual error. Maybe depreciated means we
> dont want you to use this any more but if you do its okay?

Deprecated means "obsolete": the function has been replaced by something
better, it's no longer maintained by the PHP team (if it has bugs, they
will never get fixed) and it will possibly get removed in a future
release. The notice is provided so you can update your code now you have
the chance and time, rather than a few years later when the server gets
updated and your program just stops working.

You don't need to rush and refactor right now all your legacy code
that's using this function but there's no excuse to use it in software
you are coding now.

> Anyway I thought it best to change it just in case. I googled and
> found a link to a function called preg that looks like it does the
> job.

Exactly. And there's no need to Google, it's explained right there in
the eregi manual page: http://php.net/eregi

"As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE
extension. Calling this function will issue an E_DEPRECATED notice. See
the list of differences[1] for help on converting to PCRE."

[1] http://es2.php.net/manual/en/reference.pcre.pattern.posix.php


> My question is are there any differences in the performance of eregi
> and preg?

Yes, there is. PCRE is supposed to be faster.

>
> if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.
> [a-z]{2,3})$", $allepst)){
> $emlstatus = 0; // invalid
> } else {
> $emlstatus = 1; // valid
> }
>
> if(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-
> Z]{2,6}$/i", $allepst)) {

If you use the "i" modifier you don't need to specify both lower and
uppercase: [a-zA-Z]

> $emlstatus = 0; // invalid
> } else {
> $emlstatus = 1; // valid
> }
>
> On a sidenote to this I wonder who changes the internet and why. If a
> line of code works perfectly and serves a purpose and works for years
> and years and years I don't get why anyone would want to change it.

Well, computers running from punch cards were doing their job just fine...



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Another heredoc question
Next Topic: php filling in listbox value based on db record ??
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 09:55:34 GMT 2024

Total time taken to generate the page: 0.06382 seconds