I've read everything I can find about passing arrays to functions and returning them, so I think I've got this right, but I still getting an error. Parse error: parse error, expecting `'('' in C:\xampp\htdocs\timebank\scripts\class.replace.php on line # The calling routine: include ("class.replace.php"); $stR = new clsStringReplace; $row = mysql_query($result); $cmp = $stR->ReplaceAll($row); if (!$cmp) { echo $stR->getTheError; exit(); } Code (markup): The Class: <?php class clsStringReplace { protected $SearchFor; protected $ReplaceWith; protected $Key; protected $Value; protected $myArray; protected $errorMsg; /* the constructor initializes the string replacement properties */ function __construct() { $this->SearchFor = ''; $this->ReplaceWith = ''; $this->Value = ''; $this->Key = ''; $this->errorMsg = ''; } function __toString() { return "String Replace Class"; } /* replace a specific tag */ public function ReplaceOne($pSearch, $pReplace, $pValue) { try { if (preg_match("/$pSearch/i", $pValue)) { $SearchFor = array ("/$pSearch/i"); $ReplaceWith = array ($pReplace); $Value = preg_replace($SearchFor, $ReplaceWith, $pValue); } return $Value; [color=red] } catch { // <---- this the line the error refers to[/color] $errorMsg = 'ReplaceOne: failed - $SearchFor:' . $SearchFor . '; $ReplaceWith:' . $ReplaceWith . '; $value:' . $pValue; return false; } } /* pass in a record set, replace all the tags in the values that might contain a tag */ public function ReplaceAll($row) { } } Code (markup): I'm stumped. I've checked all the () and the {} and they are all paired, so I don't know what it's complaining about.
you're not catching the exception properly. you need to catch(someException as $error) { put $error text here}, not just catch{}!
As szalinski said, you need to actually catch the exception. See the PHP.net page on exceptions for more info.