TPLix

No results for ""

Escape

3 min read Jun 2, 2026
--- title: escape autoseo: enabled: true theme: learn2 child_type: default admin: children_display_order: collection visible: true ---

escape — is used to encode or escape a variable to html, url, single quotes, hex, hexentity, javascript and mail. By default its html.

  • value: the string to process
  • format: escaping format to use, valid formats are : html, htmlall, url, urlpathinfo, quotes, hex, hexentity, javascript and mail
  • charset: character set to use for the conversion (applies to some formats only), defaults to the current Tplix charset
  • Available formats:
  • html
  • htmlall
  • url
  • urlpathinfo
  • quotes
  • hex
  • hexentity
  • javascript
  • js
  • mail
Examples:

Where template is:

{$myVar|escape}

<?php
$tplix->assign('articleTitle',
      			"'Stiff Opposition Expected to Casketless Funeral Plan'"
                );
$tplix->assign('EmailAddress','[email protected]');    
    

These are example escape template lines followed by the output


{$articleTitle}
'Stiff Opposition Expected to Casketless Funeral Plan'

{$articleTitle|escape}
'Stiff Opposition Expected to Casketless Funeral Plan'

{$articleTitle|escape:'html'}    {* escapes  & " ' < > *}
'Stiff Opposition Expected to Casketless Funeral Plan'

{$articleTitle|escape:'htmlall'} {* escapes ALL html entities *}
'Stiff Opposition Expected to Casketless Funeral Plan'

<a href="?title={$articleTitle|escape:'url'}">click here</a>
<a
href="?title=%27Stiff%20Opposition%20Expected%20to%20Casketless%20Funeral%20Plan%27">click here</a>

{$articleTitle|escape:'quotes'}
\'Stiff Opposition Expected to Casketless Funeral Plan\'

<a href="mailto:{$EmailAddress|escape:"hex"}">{$EmailAddress|escape:"hexentity"}</a>
{$EmailAddress|escape:'mail'}    {* this converts to email to text *}
<a href="mailto:%62%6f%..snip..%65%74">bob..snip..et</a>

{'[email protected]'|escape:'mail'}
tplix [AT] example [DOT] com

{* the "rewind" parameter registers the current location *}
<a href="$my_path?page=foo&rewind={$my_uri|escape:url}">click here</a>    
    

Leave a Comment

Not published. Used to notify you on approval.

Comments are moderated before appearing.