(PHP4 >= 4.0b4)

AddCSlashes -- Quote string with slashes in a C style


string addcslashes (string str, string charlist)

Returns a string with backslashes before characters that are listed in charlist parameter. It escapes \n, \r etc. in C-like style, characters with ASCII code lower than 32 and higher than 126 are converted to octal representation. Be carefull when escaping alphanumeric characters. You can specify a range in charlist like "\0..\37", which would escape all characters with ASCII code between 0 and 31.

Example 1. Addcslashes() example

$escaped = addcslashes ($not_escaped, "\0..\37!@\177..\377");

Note: Added in PHP4b3-dev.

See also stripcslashes(), stripslashes(), htmlspecialchars(), htmlspecialchars(), and quotemeta().