PHP의 quotemeta () 함수
예
미리 정의 된 백 슬래시 전 :
<?php
$str = "Hello world. (can you hear me?)";
echo quotemeta($str);
?>
$str = "Hello world. (can you hear me?)";
echo quotemeta($str);
?>
»인스턴스를 실행
정의 및 사용
quotemeta () 함수는 몇 가지 미리 정의 된 문자 전에 문자열에 백 슬래시를 추가합니다.
미리 정의 된 문자 :
- 마침표 (.)
- 백 슬래시 (\)
- 플러스 (+) 기호
- 별표 (*)
- 물음표 (?)
- 대괄호 ([])
- 캐럿 (^)
- 달러 기호 ($)
- 괄호 (())
팁 :이 기능은 문자를 이스케이프하는 데 사용할 수 있습니다 *이 []과 같은 SQL ()에서와 같이 특별한 의미를 가지고있다.
참고 :이 함수는 바이너리 안전합니다.
문법
quotemeta( string )
参数 | 描述 |
---|---|
string | 必需。规定要检查的字符串。 |
기술 세부 사항
반환 값 : | 문자열 인용 메타 문자를 돌려줍니다. |
---|---|
PHP 버전 : | 4+ |
더 많은 예제
예 1
미리 정의 된 여러 백 슬래시 전 :
<?php
$str1 = "1 + 1 = 2";
$str2 = "1 * 1 = 1";
$str3 = "Could you borrow me 5$?";
$str4 = "Are you not entertained? (I am..)";
$str5 = "The caret [ ^ ] Looks like a hat!";
echo quotemeta($str1)."<br>";
echo quotemeta($str2)."<br>";
echo quotemeta($str3)."<br>";
echo quotemeta($str4)."<br>";
echo quotemeta($str5)."<br>";
?>
$str1 = "1 + 1 = 2";
$str2 = "1 * 1 = 1";
$str3 = "Could you borrow me 5$?";
$str4 = "Are you not entertained? (I am..)";
$str5 = "The caret [ ^ ] Looks like a hat!";
echo quotemeta($str1)."<br>";
echo quotemeta($str2)."<br>";
echo quotemeta($str3)."<br>";
echo quotemeta($str4)."<br>";
echo quotemeta($str5)."<br>";
?>
»인스턴스를 실행
PHP 문자열 참조