Welcome Guest, Not a member yet? Register   Sign In
escaping output in CodeIgniter
#5

(This post was last modified: 07-24-2017, 11:05 AM by PaulD. Edit Reason: Clarification )

Assuming you have turned your object into an array it should work without looping if you wanted to do it in the controller.

Here is the function from common.php

PHP Code:
if ( ! function_exists('html_escape'))
{

 
   function html_escape($var$double_encode TRUE)
 
   {
 
       if (empty($var))
 
       {
 
           return $var;
 
       }

 
       if (is_array($var))
 
       {
 
           foreach (array_keys($var) as $key)
 
           {
 
               $var[$key] = html_escape($var[$key], $double_encode);
 
           }

 
           return $var;
 
       }

 
       return htmlspecialchars($varENT_QUOTESconfig_item('charset'), $double_encode);
 
   }


So you should be fine with:
PHP Code:
$data['user'] = html_escape($query->result_array()); 


Paul

PS Isn't that a beautifully coded function. I love learning how to code better from the CI Core...
Reply


Messages In This Thread
escaping output in CodeIgniter - by june123 - 07-24-2017, 04:27 AM
RE: escaping output in CodeIgniter - by june123 - 07-24-2017, 08:00 AM
RE: escaping output in CodeIgniter - by PaulD - 07-24-2017, 10:56 AM
RE: escaping output in CodeIgniter - by june123 - 07-25-2017, 04:44 AM
RE: escaping output in CodeIgniter - by june123 - 07-25-2017, 10:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB