The `addslashes()` string function in PHP 8.4 is used to escape certain characters in a string by adding backslashes before them. The characters that are escaped include single quotes (`'`), double quotes (`"`), backslashes (`\`), and NULL bytes. This function is particularly useful when preparing strings for storage in databases or for evaluation by `eval()`.
Syntax:<?phpaddslashes(string $string): string?>
Example:<?php$str = "Is your name O'Reilly?";$escaped_str = addslashes($str);echo $escaped_str; // Outputs: Is your name O\'Reilly??>
In this example, the single quote in "O'Reilly" is escaped with a backslash.