Example 1 — Escape Special Characters
Each special character gets a backslash in front.
<?php
echo quotemeta("1+1=2"), PHP_EOL;
echo quotemeta("Hello. (world)?"), PHP_EOL; How It Works
- The plus sign is special. It gets a backslash.
- Dots and brackets too. . ( ) and ? are all escaped.
- Other characters stay. The = sign and letters are not changed.
- Read the output. Backslashes show what was escaped.

