Home >Backend Development >PHP Tutorial >Problem reporting errors when using addslashes function in php

Problem reporting errors when using addslashes function in php

WBOY
WBOYOriginal
2016-07-25 09:05:43889browse
  1. echo function_exists('addcslashes');//Detect whether the function exists
  2. echo get_magic_quotes_gpc().'
    ';//Detect whether automatic escaping is turned on
  3. echo PHP_VERSION.'
    ';//php version information
  4. echo addcslashes("Who's John Adams?");
  5. echo '
    ';
  6. $str = "Who's John Adams?";
  7. echo addslashes($str);
  8. ?>
Copy the code

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 both functions do the same thing - escape strings. What's the difference? addslashes has only one parameter - a string addcslashes requires two parameters, string and delimiter. echo addcslashes("Who’s John Adams?","’"); If you write it like this, the output will be normal.

Hope it can help everyone understand the usage of addslashes.



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn