How to use quotemeta in PHP
In this article I will explain how the quotemeta() function can be used in PHP.
quotemeta() function in PHP
- The quotemeta() function is used to add backslashes in front of some predefined meta characters in a string.
- The quotemeta() function can be used to escape characters with special meanings
The predefined characters are:
- (.) - period
- (\) - backslash
- (+) - plus sign
- (*) - asterisk
- (?) - question mark
- ([]) - brackets
- (^) - caret
- ($) - dollar sign
- (()) - parenthesis
Syntax
Parameter
- string string is required parameter. It is check to be string.
Example
The following example show to how the quotemeta() function can be used in PHP.
<html>
<body>
<h3 style="color: darkgreen;">quotemeta() function example in PHP</h3>
<?php
$str = "C-sharpcorner. (Welcome to user....)";
echo quotemeta($str);
?>
</body>
</html>
|
Output
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here