Jump to content

htmlentities problems...


messer

Recommended Posts

I've got this error :

Warning: htmlentities() expects parameter 1 to be string, array given in /xxx/yyy/domains/wwwcom.com/public_html/some/page.php on line 11

 

And this is my function:

function addentities($data){
   if(trim($data) != ''){
   $data = htmlentities($data, ENT_QUOTES);  <------- line 11----
   return str_replace('\\', '&#92;', $data);
   } else return $data;
}

 

Anyone some ideeas???

Link to comment
https://forums.phpfreaks.com/topic/157272-htmlentities-problems/
Share on other sites

$data is an array....You can do this, but you need to figure out why it is an array:

 

function addentities($data){
   if (is_array($data)) 
          $data = implode(" ", $data);

   if(trim($data) != ''){
   $data = htmlentities($data, ENT_QUOTES);  
   return str_replace('\\', '&#92;', $data);
   } else return $data;
}

 

That will basically convert the array to a string, but you are expecting a string, the answer is not here. It is where you are calling that function, not where it is defined.

Archived

This topic is now archived and is closed to further replies.

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