Is it recommended to have a santizing function that combines two or more built in sanitizing functions in php?

后端 未结 2 1516
天涯浪人
天涯浪人 2021-01-29 03:30

Is it okay to employ a function that sanitizes the incoming inputs due to a form submission or any other request. It is time saving but the question of effectivenss and efficien

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-29 04:06

    Yes, you can create a simple function to sanitize a value before use it. I use a function like that:

    function sanitize($value)
    {
        return htmlentities(addslashes($value));
    }
    

    Which escape ' and " and convert all applicable character in html entities. Mine is more complicated with other option, but you can begin from it.

提交回复
热议问题