Jump to content

php upgraded to 5.4.25


midwestdesignfirm

Recommended Posts

Our sys admin upgraded to the most recent version of php and it broke many of our websites that we host. 

 

From the research that I have done, Function ereg_replace() is depreciated and no longer works in this version of PHP. 

 

originally the line of code was:

 

$bio = ereg_replace("\n", "</p><p>", $row["bio"]);

 

 

When i change it to:

 

$bio = preg_replace("\n", "</p><p>", $row["bio"]);

 

I get a new error:

 

Warning: preg_replace(): Empty regular expression in/home/....../public_html/filename.php on line 70

 

what am i missing? Thank you in advance for any assistance.

 

Link to comment
https://forums.phpfreaks.com/topic/286263-php-upgraded-to-5425/
Share on other sites

yes with PHP5.4 ereg is deprecated. Instead you need to use preg_replace. When changing ereg_replace to preg_replace you need to add delimiters to your regex patterns.

 

However with the code snippet you posted, it is replacing newlines with paragraph tags you could use str_replace instead

$bio = str_replace("\n", "</p><p>", $row["bio"]);

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.