char2htmlentity
1 july 2010
function smarty_function_char2htmlentity($params, &$smarty)
{
$value = arr::get($params, 't');
// '&' (ampersand) becomes '&' only when ENT_AMP is TRUE.
if ( arr::get($params, 'ENT_AMP') === TRUE )
$value = str_replace ( '&', '&', $value );
// '"' (double quote) becomes '"' when ENT_NOQUOTES is TRUE.
if ( arr::get($params, 'ENT_NOQUOTES') === TRUE )
$value = str_replace ( '"', '"', $value );
// ''' (single quote) becomes ''' only when ENT_QUOTES is TRUE.
if ( arr::get($params, 'ENT_QUOTES') === TRUE )
$value = str_replace ( '\'', ''', $value );
// '<' (less than) becomes '<' only when ENT_LT is TRUE.
if ( arr::get($params, 'ENT_LT') === TRUE )
$value = str_replace ( '<', '<', $value );
// '>' (greater than) becomes '>' only when ENT_GT is TRUE.
if ( arr::get($params, 'ENT_GT') === TRUE )
$value = str_replace ( '>', '>', $value );
return $value;
}