PHP quotemeta() ফাংশন
একটি উদাহরণ
প্রিডিফাইন্ড চার্যাকারের আগে ডার স্ক্রোল যোগ করুন:
<?php str = "Hello world. (can you hear me?)"; echo quotemeta($str); ?>
Definition and Usage
The quotemeta() function adds a backslash before certain predefined characters in a string.
Predefined characters:
- Period (.)
- Backslash (\)
- Plus (+)
- Asterisk (*)
- Question mark (?)
- Square brackets ([])
- Tilde (^)
- Dollar sign ($)
- Round brackets (())
Tip:This function can be used to escape special characters, such as ( ) in SQL, [ ] and * .
Note:This function is binary safe.
Syntax
quotemeta(string)
Parameter | Description |
---|---|
string | Required. Specifies the string to be checked. |
Technical Details
Return value: | Returns a string that contains the escaped meta characters. |
PHP Version: | 4+ |
More Examples
Example 1
Add a backslash before multiple predefined characters:
<?php $str1 = "1 + 1 = 2"; $str2 = "1 * 1 = 1"; $str3 = "Could you borrow me 5$?"; $str4 = "Are you not e&"; $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>"; ?>