Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php安全输出_Php_Sanitize - Fatal编程技术网

Php安全输出

Php安全输出,php,sanitize,Php,Sanitize,输出用户输入时,我使用此功能: function bbkoda($text) { $text = htmlspecialchars($text); $text = nl2br($text); $hitta = array( "'\[b](.*?)\[/b]'is", "'\[i](.*?)\[/i]'is" ); $byt = array( "<b>\\1</b>",

输出用户输入时,我使用此功能:

function bbkoda($text) {
    $text = htmlspecialchars($text);
    $text = nl2br($text);

    $hitta = array(
        "'\[b](.*?)\[/b]'is",
        "'\[i](.*?)\[/i]'is"
    );

    $byt = array(
        "<b>\\1</b>",
        "<i>\\1</i>"
    );

    $text = preg_replace($hitta, $byt, $text);

    return $text;
}
函数bbkoda($text){
$text=htmlspecialchars($text);
$text=nl2br($text);
$hitta=数组(
“'\[b](.*?\[/b]'是”,
“\[i](.*?\[/i]”是”
);
$byt=数组(
"\\1",
"\\1"
);
$text=preg_replace($hitta,$byt,$text);
返回$text;
}
这很安全,对吧?我用
mysql\u real\u escape\u string
清理插入数据库的所有内容,并用
htmlspecialchars
输出。我是一个非常怀疑的人:P


谢谢

关于这个话题已经有了很好的解释。基本上,你肯定需要对你的输入和输出工作,以获得真正的安全

与其使用BB代码,不如使用标记或重构文本。