Skip to content

Instantly share code, notes, and snippets.

@lenivene
Last active March 11, 2016 18:11
Show Gist options
  • Save lenivene/31f503464d1d4d53f8e6 to your computer and use it in GitHub Desktop.
Save lenivene/31f503464d1d4d53f8e6 to your computer and use it in GitHub Desktop.
Escaping variables
<?php
/**
* I used on a project.
* Author: Lenivene Bezerra
*/
function esc_var( $t ){
$e = 'UTF-8';
return mb_convert_encoding( htmlentities( $t, ENT_QUOTES, $e ), $e, $e );
}
<?php
/**
* I used on a project.
* Author: Lenivene Bezerra
*/
function esc_var( $text ){
$safe_text = mb_convert_encoding( $text, 'UTF-8', 'UTF-8' );
$safe_text = htmlentities( $safe_text, ENT_QUOTES, 'UTF-8' );
return $safe_text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment