entropicsinkhole Posted November 9, 2009 Share Posted November 9, 2009 Ever since I upgraded to php 5.3, a program I've been running for awhile now has "eregi_replace() is deprecated" errors that point at this specific line as the culprit: <textarea name="messageText" rows="5" cols="75" wrap="off"><?php echo eregi_replace('<br[[:space:]]*/?[[:space:]]*>', "\n", $messageText); ?></textarea> What can I replace this with? Link to comment https://forums.phpfreaks.com/topic/180901-eregi_replace-is-deprecated-problem/ Share on other sites More sharing options...
Mchl Posted November 9, 2009 Share Posted November 9, 2009 preg_replace Link to comment https://forums.phpfreaks.com/topic/180901-eregi_replace-is-deprecated-problem/#findComment-954321 Share on other sites More sharing options...
Daniel0 Posted November 9, 2009 Share Posted November 9, 2009 You might also want to read Migrating from PHP 5.2.x to PHP 5.3.x in the manual. Link to comment https://forums.phpfreaks.com/topic/180901-eregi_replace-is-deprecated-problem/#findComment-954325 Share on other sites More sharing options...
entropicsinkhole Posted November 9, 2009 Author Share Posted November 9, 2009 Ugh, I probably should have mentioned I'm not a programmer and most of this is Greek to me :-/ I'm guessing that using preg_replace() instead of the eregi_replace() involves completely changing the syntax of the regex stuff in the brackets? Or can I leave it the same? The program in question is no longer maintained by the guy who made it, so I'm trying to see if I can salvage it Fun times. Link to comment https://forums.phpfreaks.com/topic/180901-eregi_replace-is-deprecated-problem/#findComment-954362 Share on other sites More sharing options...
Daniel0 Posted November 9, 2009 Share Posted November 9, 2009 In this case, you can change eregi_replace('<br[[:space:]]*/?[[:space:]]*>', "\n", $messageText); to preg_replace('#<br\s*/?\s*>#', "\n", $messageText); Link to comment https://forums.phpfreaks.com/topic/180901-eregi_replace-is-deprecated-problem/#findComment-954367 Share on other sites More sharing options...
.josh Posted November 10, 2009 Share Posted November 10, 2009 for a more accruate translation you would need to add the i modifier. Link to comment https://forums.phpfreaks.com/topic/180901-eregi_replace-is-deprecated-problem/#findComment-954639 Share on other sites More sharing options...
entropicsinkhole Posted November 10, 2009 Author Share Posted November 10, 2009 Thanks! That got rid of the error. Doesn't fix some other issues, but I'm going to play around with it Link to comment https://forums.phpfreaks.com/topic/180901-eregi_replace-is-deprecated-problem/#findComment-954878 Share on other sites More sharing options...
entropicsinkhole Posted November 10, 2009 Author Share Posted November 10, 2009 So continuing with my issues, now that I've gone through the deprecated functions, etc. This time with the split() function. I tried using the preg_split function in its place and tried to figure out the syntax myself. It doesn't seem to be doing anything different, so I wanted to check my syntax Original : echo 'parts = date.split("-");'._NL; echo 'parts = date.split(".");'._NL; My Edit : echo 'parts=date.preg_split("/[-]/");'._NL; echo 'parts=date.preg_split("/\./");'._NL; Link to comment https://forums.phpfreaks.com/topic/180901-eregi_replace-is-deprecated-problem/#findComment-954967 Share on other sites More sharing options...
.josh Posted November 10, 2009 Share Posted November 10, 2009 that's because your original is javascript which is a clientside language, whereas preg_split is php which is a serverside language. The php equivalent of js's split is explode but clientside and serverside are two different environments... Link to comment https://forums.phpfreaks.com/topic/180901-eregi_replace-is-deprecated-problem/#findComment-954970 Share on other sites More sharing options...
Mchl Posted November 10, 2009 Share Posted November 10, 2009 In other words, these two lines should be left as is. Link to comment https://forums.phpfreaks.com/topic/180901-eregi_replace-is-deprecated-problem/#findComment-954974 Share on other sites More sharing options...
entropicsinkhole Posted November 10, 2009 Author Share Posted November 10, 2009 Thanks! Link to comment https://forums.phpfreaks.com/topic/180901-eregi_replace-is-deprecated-problem/#findComment-955012 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.