Home > Article > Backend Development > Solution to error reporting problem using addslashes function in PHP_PHP Tutorial
Look at the code below. Can you find the error?
Are the output results the same?
10
5.3.6
Warning: addcslashes() expects exactly 2 parameters, 1 given in /data/bookuu/test/class.php on line 50
Who's John Adams?
One reports an error and the other outputs normally. Why?
addslashes and addcslashes are not the same function. I found that there is no difference, only one character.
But the function of both functions is the same—escape strings.
What’s the difference?
addslashes has only one parameter - string
addcslashes requires two parameters, string and delimiter.
echo addcslashes("Who's John Adams?","'"); If you write it like this, you can output it normally. .
Hope it helps everyone understand the usage of addslashes.
Error in addslashes
What a fool, let me show you a code and see if you can find the error?
Guess whether the output results are the same? ? ? A: Same B: Still the same
I also think it’s the same, but it’s actually a lie!
10
5.3.6
Warning: addcslashes() expects exactly 2 parameters, 1 given in /data/bookuu/test/class.php on line 50
Who's John Adams?
One reports an error and the other outputs normally.
Why?
addslashes and addcslashes are not the same function. I found that there is no difference, only one character.
But the function of both functions is the same—escape strings.
What’s the difference?
addslashes has only one parameter - string
addcslashes requires two parameters, string and delimiter.
echo addcslashes("Who's John Adams?","'"); If you write it like this, you can output it normally. .