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

情到浓时终转凉″ 提交于 2019-12-02 12:38:20

each function serves its own purpose, you shouldn't use any function not for their intended use.

  1. you should use mysql_real_escape_string before using the parameter in mysql query.
  2. you should use htmlspecialchars before outputting to page.

that's about it.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!