quotemeta() function in PHP 8.5 & 8.4

The quotemeta() function in PHP 8.5 (and 8.4) works exactly as it did in previous versions. Its purpose is to escape meta characters by adding a backslash () before each one.

What It Does?

It escapes these specific characters: . + * ? [ ^ ] ( $ ) .

Basic Usage Example

<?php
var_dump(quotemeta( PHP is a popular scripting language. Fast, flexible, and pragmatic. ));
?>

Output:

string(69) "PHP is a popular scripting language. Fast, flexible, and pragmatic."
The period (.) became . .

 

No Change in PHP 8.5:

  • The function is stable across PHP 8.x. The PHP 8.5 release notes do not mention any changes, deprecations, or removals for quotemeta().
13 Views