hanlonj Posted June 30, 2007 Share Posted June 30, 2007 Guys, Can someone let me know why one would use strip slashes or add slashes functions. I know what they do but cannot see the exact use for them e.g. if i have a textfield and encase it in an stripslashes function, it will escape any back slashes etc...What advantage is this please? Hanlonj Link to comment https://forums.phpfreaks.com/topic/57831-solved-why-use-stripslashes-and-addslashes-function/ Share on other sites More sharing options...
Vikas Jayna Posted June 30, 2007 Share Posted June 30, 2007 addslashes is used to put back slashes in front of quotes so as to avoid syntax errors in sql queries in case the query contains some values that are taken from a text field. Stripslashes would be used to remove the slashes in case we don't want them. For e.g. quite often magic_quotes_gpc is set to On in php.ini so that slashes are automatically added in from of quotes and there is no need to explicitly use addslashes. It is good to keep magic_quotes_gpc On so as to avoid SQL Injection attacks. But in this case if the values taken from the text field is to be displayed somewhere then the extra slash would appear in the output and hence stripslashes is used to remove the same. Link to comment https://forums.phpfreaks.com/topic/57831-solved-why-use-stripslashes-and-addslashes-function/#findComment-286529 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.