What is the best practice for handling backslashes in PHP functions to prevent them from disappearing?

When working with backslashes in PHP functions, it's important to escape them properly to prevent them from disappearing. One common way to handle this is by using double backslashes (\\) to represent a single backslash in a string. This ensures that the backslashes are treated as literal characters and not escape characters.

// Example of handling backslashes in PHP functions
$input = "C:\\Users\\John\\Documents";
$escaped_input = str_replace("\\", "\\\\", $input);

echo $escaped_input;