PHP quotemeta () function
contoh
Sebelum telah ditetapkan garis miring terbalik:
<?php
$str = "Hello world. (can you hear me?)";
echo quotemeta($str);
?>
$str = "Hello world. (can you hear me?)";
echo quotemeta($str);
?>
Menjalankan contoh »
Definisi dan Penggunaan
quotemeta () fungsi untuk menambahkan backslash dalam string sebelum beberapa karakter yang telah ditetapkan.
karakter yang telah ditetapkan:
- Titik (.)
- Backslash (\)
- Tanda plus (+)
- Tanda bintang (*)
- Pertanyaan tanda (?)
- kurung siku ([])
- Sisipan (^)
- Dolar tanda ($)
- Kurung (())
Tip: Fungsi ini dapat digunakan untuk melarikan diri karakter memiliki arti khusus, seperti di SQL (), [] dan *.
Catatan: Fungsi ini aman biner.
tatabahasa
quotemeta( string )
参数 | 描述 |
---|---|
string | 必需。规定要检查的字符串。 |
rincian teknis
Pengembalian: | Mengembalikan string kutipan metakarakter. |
---|---|
Versi PHP: | 4+ |
contoh yang lebih
contoh 1
Sebelum beberapa yang telah ditetapkan garis miring terbalik:
<?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>";
?>
Menjalankan contoh »
PHP String Reference