addcslashes -- Quote string with slashes in a C style
Returns a string with backslashes before characters that are listed in charlist parameter.
addcslashes ( string str,
string charlist )
When
you define a sequence of characters in the charlist argument make sure that you know what characters come between the characters that you set as the start and end of the range.
[php]<?php
echo addcslashes('foo[ ]', 'A..z');
// output: \f\o\o\[ \]
// All upper and lower-case letters will be escaped
// ... but so will the [\]^_` and any tabs, line
// feeds, carriage returns, etc.
?> [/php]
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
addslashes -- Quote string with slashes
Returns a string with backslashes before
characters that need to be quoted in database queries etc. These characters are single quote ('), double quote ("), backslash (\) and NUL (the NULL byte).
addslashes ( string str )
[php]<?php
$str = "Is your name O'reilly?";
// Outputs: Is your name O\'reilly?
echo addslashes($str);
?> [/php]
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Basically, addslashes() adds slashes to predefined dangerous characters while addcslashes() lets YOU define the characters to add slashes too.
Get it?
