MiWBC Posted July 19, 2014 Share Posted July 19, 2014 Can anyone help me with this - I don't normally do coding. I've just moved an old site onto new hosting and I'm getting this message: Deprecated: Function ereg_replace() is deprecated The code looks like this: if( preg_match( '/sl/i', $sOption ) ) $sContent = addslashes( $sContent ); else $sContent = stripslashes( $sContent ); $sContent = ereg_replace( "\r", '', $sContent ); if( preg_match( '/len/i', $sOption ) ) $sContent = checkLengthOfTxt( $sContent ); I changed it to look like this: if( preg_match( '/sl/i', $sOption ) ) $sContent = addslashes( $sContent ); else $sContent = stripslashes( $sContent ); $sContent = preg_replace( "\r", '', $sContent ); if( preg_match( '/len/i', $sOption ) ) $sContent = checkLengthOfTxt( $sContent ); But now get this warning message: Warning: preg_replace() [function.preg-replace]: Empty regular expression I didn't build the site so I don't even know what the script is trying to do - forgive my ignorance! Quote Link to comment https://forums.phpfreaks.com/topic/289990-deprecated-function-ereg_replace-is-deprecated/ Share on other sites More sharing options...
Solution requinix Posted July 20, 2014 Solution Share Posted July 20, 2014 ereg and preg are for regular expressions - things much more complicated than simple strings like "\r". Use str_replace instead. Quote Link to comment https://forums.phpfreaks.com/topic/289990-deprecated-function-ereg_replace-is-deprecated/#findComment-1485716 Share on other sites More sharing options...
MiWBC Posted July 20, 2014 Author Share Posted July 20, 2014 Thank you! That did the trick - works fine now Quote Link to comment https://forums.phpfreaks.com/topic/289990-deprecated-function-ereg_replace-is-deprecated/#findComment-1485736 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.