Fix-> Warning: ereg_replace(): REG_BADRPT in PHP

PHP Scripts Add comments

If you are a PHP programmer and if you are using regular expressions with ereg_replace then often with replacing particular characters you might encounter error like

Warning: ereg_replace(): REG_BADRPT

Here is a simple function that causes this error


function OrigURL($str)
{
$out = ereg_replace('+',' ',$str);
return $out;
}

Solution: Just escape the characters. Only then it will work.

$out = ereg_replace(’\+’,’ ‘,$str);

Hope this would help!

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • BlinkList
  • blogmarks
  • del.icio.us
  • digg
  • feedmelinks
  • Furl
  • Fleck
  • MyShare
  • NewsVine
  • Netscape
  • Slashdot
  • Spurl
  • StumbleUpon
  • Taggly
  • Technorati
  • Wists
  • YahooMyWeb

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Login