PHP quotemeta function ()
Przykłady
Przed ustawionego backslashem:
<?php
$str = "Hello world. (can you hear me?)";
echo quotemeta($str);
?>
$str = "Hello world. (can you hear me?)";
echo quotemeta($str);
?>
Uruchomienie instancji »
Definicja i Wykorzystanie
Funkcja quotemeta (), aby dodać ukośnik w łańcuchu przed kilku predefiniowanych znaków.
Predefiniowane znaki:
- Kropka (.)
- Backslash (\)
- Znak plus (+)
- Gwiazdka (*)
- Znak zapytania (?)
- nawiasy kwadratowe ([])
- Daszka (^)
- Znak dolara ($)
- Nawiasy (())
Wskazówka: Funkcja ta może być używana do ucieczki znaki mają specjalne znaczenie, jak w SQL () [] i *.
Uwaga: Funkcja ta jest bezpieczny binarny.
gramatyka
quotemeta( string )
参数 | 描述 |
---|---|
string | 必需。规定要检查的字符串。 |
dane techniczne
Zwraca: | Zwraca metaznaki ciąg cytatów. |
---|---|
Wersja PHP: | 4+ |
Więcej przykładów
Przykład 1
Przed kilku predefiniowanych backslashem:
<?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>";
?>
Uruchomienie instancji »
PHP referencyjny String