#1
  1. A Change of Season
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,246
    Rep Power
    220

    html_escape not working


    Hi

    I am using CI's html_escape as below but it's not working and the page alerts "HI".

    What's wrong?

    Code:
    <input type = "text" name = "robot" value = "<?php echo html_escape($_SESSION['robot']);?>" class = "form-control">
    PHP Code:
    if ( ! function_exists('html_escape'))
    {
        
    /**
         * Returns HTML escaped variable.
         *
         * @param    mixed    $var        The input string or array of strings to be escaped.
         * @param    bool    $double_encode    $double_encode set to FALSE prevents escaping twice.
         * @return    mixed            The escaped string or array of strings as a result.
         */
        
    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);
        }

  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,350
    Rep Power
    630
    Looks to me that you are trying to test the existence of the function before you define it.

    Comments on this post

    • Winters agrees
    There are 10 kinds of people in the world. Those that understand binary and those that don't.

IMN logo majestic logo threadwatch logo seochat tools logo