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! Link to comment https://forums.phpfreaks.com/topic/289990-deprecated-function-ereg_replace-is-deprecated/ Share on other sites More sharing options...
requinix Posted July 20, 2014 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. 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 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
Archived
This topic is now archived and is closed to further replies.