November 12th in PHP Scripts by .

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

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!

Similar Posts:

One Comment

  • iju
    January 23, 2009

Leave A Comment.





Please wrap all source codes with [code][/code] tags. Powered by