Solution to error reporting problem using addslashes function in PHP_PHP Tutorial

WBOY
Release: 2016-07-21 15:13:50
Original
1083 people have browsed it

Look at the code below. Can you find the error?

Copy code The code is as follows:

echo function_exists('addcslashes');//Detection Whether this function exists
echo get_magic_quotes_gpc().'
';//Check whether automatic escaping is turned on
echo PHP_VERSION.'
';//php version information
echo addcslashes("Who's John Adams?");
echo '
';
$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 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?

Copy code The code is as follows:

echo function_exists('addcslashes');//Detect whether the function exists
echo get_magic_quotes_gpc().'
';//Check whether automatic escaping is turned on
echo PHP_VERSION.'
';//php version information
echo addcslashes("Who's John Adams?");
echo '
';
$str = "Who's John Adams?";
echo addslashes($str);

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. .

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326448.htmlTechArticleLook at the code below, can you find the error? Copy the code The code is as follows: ?php echo function_exists('addcslashes');//Check whether the function exists echo get_magic_quotes_gp...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template