string addslashes ( string $str
)
single quote (')
double quote (")
backslash (\)
NUL (the NUL byte)
위의 기호들을 \을 붙여서 return해주는 함수로, 대개 sql injection등을 방어할 때에 효과적으로 쓰인다.
예)
"'hello world"' -> \"\'hello world\'\"
<?php
$str = "Who's Peter Griffin?";
echo $str . " This is not safe in a database query.<br>";
echo addslashes($str) . " This is safe in a database query.";
?>
--->
Who's Peter Griffin? This is not safe in a database query.
Who\'s Peter Griffin? This is safe in a database query.
'함수들' 카테고리의 다른 글
isset() 함수 (0) | 2018.02.01 |
---|---|
strtolower()함수 (0) | 2018.01.10 |
trim()함수 (0) | 2018.01.10 |
getenv()함수 (0) | 2018.01.10 |
alert()함수 (0) | 2018.01.08 |