Jump to: navigation, search

Php quotemeta

From w3cyberlearnings

Contents

PHP function quotemeta

This function adds backslashes in front of the predefined characters in a string.

Syntax quotemeta

  • string: string input

Predefined characters list: . \ + * ? [ ^ ] ( $ ).

quotemeta(string);

Example 1

<?php

$str = "Leader makes change. Manager manages change. Leader + Mange = Great";
echo quotemeta($str);
?>

Output

 Leader makes change\. Manager manages change\. Leader \+ Mange = Great

Example 2

<?php

$str1 = '19 + 1 = 20';
$str2 = '20 * 2 = 40';
$str3 = '20$ is 10$ + 10$';
$str4 = '2 ^ 2 = 4';
$str5 = '3 ^ 3 = ?';

echo quotemeta($str1);
echo "<br/>";

echo quotemeta($str2);
echo "<br/>";

echo quotemeta($str3);
echo "<br/>";

echo quotemeta($str4);
echo "<br/>";

echo quotemeta($str5);
echo "<br/>";
?>

Output

19 \+ 1 = 20
20 \* 2 = 40
20\$ is 10\$ \+ 10\$
2 \^ 2 = 4
3 \^ 3 = \?

Related Functions


Navigation
Web
SQL
MISC
References