Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save huuyafwww/1b50f5604493addb1b2391b83d764bb1 to your computer and use it in GitHub Desktop.

Select an option

Save huuyafwww/1b50f5604493addb1b2391b83d764bb1 to your computer and use it in GitHub Desktop.
<pre>
<?php
/**
* All of the Arguments do Sanitize
*
* @param string|array $__stringer
* @return string|array
*/
function __h(
&$__stringer
)
{
if(
is_array($__stringer)
||
!$__stringer = htmlspecialchars($__stringer)
)
{
foreach(
$__stringer
as
&$__string
)
{
$__string = htmlspecialchars($__string);
}
}
}
$str_array = [
"<h1>H1です🤗</h1>"
];
$str = "<h1>H1です🤗</h1>";
__h($str);
__h($str_array);
print_r($str);
print_r($str_array);
@huuyafwww
Copy link
Copy Markdown
Author

活用方法としては、
__h($_POST);
__h($_GET);のように
リクエストbodyのすべてにサニタイズを行うような事象。

また$_POST$_GETグローバルスコープなため、
上記を実行した後にスコープ外でもサニタイズされたリクエストbodyのまま評価することが可能になる

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment