Jump to content

php upgraded to 5.4.25


Go to solution Solved by 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"]);
Edited by Ch0cu3r
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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