Powerz Posted February 23, 2012 Share Posted February 23, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/257636-problem-with-eregi/ Share on other sites More sharing options...
AyKay47 Posted February 23, 2012 Share Posted February 23, 2012 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); Quote Link to comment https://forums.phpfreaks.com/topic/257636-problem-with-eregi/#findComment-1320474 Share on other sites More sharing options...
Psycho Posted February 23, 2012 Share Posted February 23, 2012 If I am understanding that expression correctly you could simplify that as preg_match( "~^[\w-/]+$~", $value ) Quote Link to comment https://forums.phpfreaks.com/topic/257636-problem-with-eregi/#findComment-1320478 Share on other sites More sharing options...
AyKay47 Posted February 23, 2012 Share Posted February 23, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/257636-problem-with-eregi/#findComment-1320479 Share on other sites More sharing options...
Psycho Posted February 23, 2012 Share Posted February 23, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/257636-problem-with-eregi/#findComment-1320490 Share on other sites More sharing options...
AyKay47 Posted February 23, 2012 Share Posted February 23, 2012 yes, my mistake on that part. Quote Link to comment https://forums.phpfreaks.com/topic/257636-problem-with-eregi/#findComment-1320494 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.