Page 1 of 1

Only variable references should be returned by reference

Posted: Tue Apr 11, 2006 10:27 am
by tornup
Hi,

I am trying to install Xoops Custom Installation, and I am getting the following error
"Notice: Only variable references should be returned by reference in C:\Apache2\Apache2\htdocs\xoop\html\install\class\textsanitizer.php on line 96"

Line 96 of textsanitizer.php is:

Code: Select all

/* for displaying data in html textbox forms */

function &htmlSpecialChars($text)
{  
	return preg_replace("/&/i", '&', htmlspecialchars($text, ENT_QUOTES));
}
Can someone help me figure out what is wrong here. Thanks.

Nina

Re: Only variable references should be returned by reference

Posted: Tue Apr 11, 2006 11:50 am
by timvw
Try:

Code: Select all


/* for displaying data in html textbox forms */

function &htmlSpecialChars($text)
{  
  $result = preg_replace("/&/i", '&', htmlspecialchars($text, ENT_QUOTES));
  return $result;
}

Re: Only variable references should be returned by reference

Posted: Tue Apr 11, 2006 12:32 pm
by tornup
Thanks so much. It worked!

Posted: Tue Apr 11, 2006 12:51 pm
by Christopher
This call should probably not use references at all, and just be:

Code: Select all

function htmlSpecialChars($text)
{ 
   return preg_replace("/&/i", '&', htmlspecialchars($text, ENT_QUOTES));
}