Jump to content

Recommended Posts

Hello.I got some error in my code:

Deprecated: Function eregi() is deprecated in config.php on line 84

 

This is my code

 

if(!eregi( "^[a-zA-Z\-_0-9/-]+$", $type )) unset($type);

if(!eregi( "^[a-zA-Z\-_0-9/]+$", $act )) unset($act);

if(!eregi( "^[a-zA-Z\-_0-9/]+$", $id )) unset($id);

 

Can someone help me what should be changed  :shrug:

 

 

Link to comment
https://forums.phpfreaks.com/topic/257636-problem-with-eregi/
Share on other sites

Yes, the function has been deprecated as of PHP version 5.3.0

you can use preg_match instead.

 

if(!preg_match( "~^[-a-zA-Z_0-9/]+$~i", $type )) unset($type);
if(!preg_match( "~^[a-zA-Z\-_0-9/]+$~i", $act )) unset($act);
if(!preg_match( "~^[a-zA-Z\-_0-9/]+$~i", $id )) unset($id);

Link to comment
https://forums.phpfreaks.com/topic/257636-problem-with-eregi/#findComment-1320474
Share on other sites

If I am understanding that expression correctly you could simplify that as

preg_match( "~^[\w-/]+$~", $value )

 

yes, another way of writing it, except that you want to keep the dash immediately following the opening character class bracket so it is not treated as a meta-character. Also, the OP was using eregi(), which performs a case-insensitive search, thus the reason for the appended "i" modifier.

Link to comment
https://forums.phpfreaks.com/topic/257636-problem-with-eregi/#findComment-1320479
Share on other sites

If I am understanding that expression correctly you could simplify that as

preg_match( "~^[\w-/]+$~", $value )

 

yes, another way of writing it, except that you want to keep the dash immediately following the opening character class bracket so it is not treated as a meta-character. Also, the OP was using eregi(), which performs a case-insensitive search, thus the reason for the appended "i" modifier.

 

Right, but doesn't the use of \w remove the need to use 'i' for case insensitivity?

Link to comment
https://forums.phpfreaks.com/topic/257636-problem-with-eregi/#findComment-1320490
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.