Let's look at the following code. Can you find out where the error is?
Copy codeThe Code is as follows: <? Php
Echo function_exists ('addcslashes'); // checks whether the function exists.
Echo get_magic_quotes_gpc (). '<br/>'; // checks whether automatic escape is enabled.
Echo PHP_VERSION. '<br/>'; // php version information
Echo addcslashes ("Who's John Adams? ");
Echo '<br/> ';
$ Str = "Who's John Adams? ";
Echo addslashes ($ str );
?>
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 error and the other normal output. Why?
Addslashes and addcslashes are not the same function. They are not found to have only one character.
However, the functions of both functions are the same-escape strings.
What is the difference?
Addslashes only has one parameter-string
Addcslashes requires two parameters: string and delimiter.
Echo addcslashes ("Who's John Adams? "," '"); In this way, the output can be normally written.
I hope to help you understand the usage of addslashes.
Addslashes Error
Sorry, I want to show you a code to see if you can find any errors?
Copy codeThe Code is as follows: echo function_exists ('addcslashes'); // checks whether the function exists.
Echo get_magic_quotes_gpc (). '<br/>'; // checks whether automatic escape is enabled.
Echo PHP_VERSION. '<br/>'; // php version information
Echo addcslashes ("Who's John Adams? ");
Echo '<br/> ';
$ Str = "Who's John Adams? ";
Echo addslashes ($ str );
Do you think the output results are the same ??? A: Same B: the same
I also think the same thing, but it's actually a pitfall!
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 error and the other normal output.
Why?
Addslashes and addcslashes are not the same function. They are not found to have only one character.
However, the functions of both functions are the same-escape strings.
What is the difference?
Addslashes only has one parameter-string
Addcslashes requires two parameters: string and delimiter.
Echo addcslashes ("Who's John Adams ?"," '"); In this way, the output can be normally written.