db2_escape_string
(PECL ibm_db2 >= 1.6.0)
db2_escape_string — 특정 문자를 이스케이프하는 데 사용됩니다.
설명
db2_escape_string(string $string_literal
): string
문자열 인수의 특수 문자 앞에 백슬래시를 추가합니다.
매개변수
string_literal
- 수정해야 하는 특수 문자가 포함된 문자열입니다. 백슬래시가 앞에 붙는 문자는
\x00
,\n
,\r
,\
,'
,"
및\x1a
입니다.
반환 값
백슬래시가 앞에 추가된 위에서 언급한 특수 문자가 있는 string_literal
을 반환합니다.
Examples
예제 #1 db2_escape_string() 예제
db2_escape_string() 함수를 사용한 결과
<?php
$conn = db2_connect($database, $user, $password);
if ($conn) {
$str[0] = "All characters: \x00 , \n , \r , \ , ' , \" , \x1a .";
$str[1] = "Backslash (\). Single quote ('). Double quote (\")";
$str[2] = "The NULL character \0 must be quoted as well";
$str[3] = "Intersting characters: \x1a , \x00 .";
$str[4] = "Nothing to quote";
$str[5] = 200676;
$str[6] = "";
foreach( $str as $string ) {
echo "db2_escape_string: " . db2_escape_string($string). "\n";
}
}
?>
위의 예는 다음을 출력합니다.
db2_escape_string: All characters: \0 , \n , \r , \\ , \' , \" , \Z . db2_escape_string: Backslash (\\). Single quote (\'). Double quote (\") db2_escape_string: The NULL character \0 must be quoted as well db2_escape_string: Intersting characters: \Z , \0 . db2_escape_string: Nothing to quote db2_escape_string: 200676 db2_escape_string:
기타
- db2_prepare() - 실행할 SQL 문을 준비합니다.