PHP code example of initphp / escaper
1. Go to this page and download the library: Download initphp/escaper library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
initphp / escaper example snippets
use InitPHP\Escaper\Esc;
echo Esc::esc('<script>alert(1)</script>');
// <script>alert(1)</script>
echo Esc::esc('faketitle onmouseover=alert(1);', 'attr');
// faketitle onmouseover=alert(1);
echo Esc::esc('"; alert(1); var x="', 'js');
// \x22\x3B\x20alert\x281\x29\x3B\x20var\x20x\x3D\x22
echo Esc::esc('</style><script>alert(1)</script>', 'css');
// \3C \2F style\3E \3C script\3E alert\28 1\29 \3C \2F script\3E
echo Esc::esc('" onmouseover="alert(1)', 'url');
// %22%20onmouseover%3D%22alert%281%29
$safe = Esc::esc($_GET, 'html');
public static function esc(
array|string $data,
string $context = 'html',
?string $encoding = null
): array|string;
use InitPHP\Escaper\Escaper;
$escaper = new Escaper(); // utf-8
$escaper = new Escaper('windows-1252');
$escaper->escHtml($string);
$escaper->escHtmlAttr($string);
$escaper->escJs($string);
$escaper->escCss($string);
$escaper->escUrl($string);