Home >Backend Development >PHP Tutorial >PHP filters dangerous codes submitted by forms (preventing PHP injection)_PHP tutorial

PHP filters dangerous codes submitted by forms (preventing PHP injection)_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:11:16868browse

If the security of form submission is not done well, it is easy for the website to be attacked due to this form submission. Let me share two commonly used PHP methods. For examples of filtering dangerous codes submitted through forms, friends in need can refer to them.

Example 1

The code is as follows
 代码如下 复制代码

function uhtml($str) 

    $farr = array( 
        "/s+/", //过滤多余空白 
         //过滤