Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In PHP, what's the diff between 'stripcslashes' and 'stripslashes'?

Tags:

php

just.... don't know why two strip slash function.

like image 635
lovespring Avatar asked Nov 04 '09 05:11

lovespring


2 Answers

stripcslashes() skips special character sets like "\n" and "\r", preserving any line breaks, return carriages, etc. that may be in the string.

stripslashes() simply removes any slashes it encounters without parsing anything beforehand.

like image 179
BraedenP Avatar answered Nov 07 '22 02:11

BraedenP


stripcslashes does not simply skip the C-style escape sequences \a, \b, \f, \n, \r, \t and \v, but converts them to their actual meaning. So

stripcslashes('\n') == "\n"

while

stripslashes('\n') == "n"

Note that '\n' == "\\n".

like image 38
bodo Avatar answered Nov 07 '22 03:11

bodo