How to use quotemeta in PHP

In this article I will explain how the quotemeta() function can be used in PHP.
  • 1538

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

quotemeta(string)

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

quotemeta-php.gif
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
 

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.