Back to HtmlView class

Method escape

public mixed
escape
(mixed $var)
Escapes a value for output in a view script.
Parameters
  • mixed $var The output to escape.
Returns
  • mixed The escaped value.
Since
  • 3.0
-
  • the ENT_COMPAT flag was replaced by ENT_QUOTES in Joomla 4.0 to also escape single quotes
Class: HtmlView
Project: Joomla

Method escape - Source code

/**
 * Escapes a value for output in a view script.
 *
 * If escaping mechanism is htmlspecialchars, use
 * {@link $_charset} setting.
 *
 * @param   mixed  $var  The output to escape.
 *
 * @return  mixed  The escaped value.
 *
 * @note the ENT_COMPAT flag was replaced by ENT_QUOTES in Joomla 4.0 to also escape single quotes
 *
 * @since   3.0
 */
public function escape($var)
{
    if ($var === null) {
        return '';
    }
    return htmlspecialchars($var, ENT_QUOTES, $this->_charset);
}