Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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