htmlspecialchars() expects parameter 1 to be string, object given error in COdeIgniter

前端 未结 1 1461
北恋
北恋 2021-01-29 05:16

When assigning a type casted array to codeigniter\'s session, I get this error:

A PHP Error was encountered 
Severity: Warning

Message: htmlspecialchars() expe         


        
相关标签:
1条回答
  • 2021-01-29 05:29

    The CodeIgniter profiler breaks as soon as you store any non-array non-strings in its session:

    foreach ($this->CI->session->all_userdata() as $key => $val)
    {
        if (is_array($val))
        {
            $val = print_r($val, TRUE);
        }
    
        $output .= "<...>".htmlspecialchars($val)."<...>\n";
    }
    

    (from CI_Profiler::_compile_session_data())

    This looks like a pretty stupid thing since print_r() works fine with objects - so is_array($val) || is_object($val) would be more appropriate.

    0 讨论(0)
提交回复
热议问题