The major idea where I would use stripslashes is to clean up the input from a form prior to processing this input with your own code. This removes any possibility that a user entered any slashes by mistake into your form that would foul up the interpretor.
Your own code after cleaning by the stripslashes would require any slashes to escape any characters required, such as for quote characters or other HTML characters within your PHP code (/n for newline etc.). However, with magic quotes turned on these characters might not escape properly or PHP will attempt to place another slash mark before the character. That is the reason it is best to turn it off if you already have that capability. You cannot predict what might happen with magic quotes!
If you already have placed some stripslashes in your code to remove slashes you would need to make certain that the characters requiring the proper escape slashes are inserted after your stripslashes coding was implemented.
If you leave magic quotes turned on (which is not a good idea if you can turn it off) then you must use the stripslashes in your code to make certain that no extraneous slashes remain to confuse PHP in interpreting some of your HTML characters that might already be escaped. Magic Quotes is not reliable and can attempt to insert escape characters that are duplicates or in areas not valid in PHP.
My own code for using stripslashes is the following and it is placed at the very beginning of any input from any form data to my site:
// first, check for "magic_quotes_gpc" if it is on
if ( ini_get( 'magic_quotes_gpc' ) ) {
// strip the spaces, tags, and slashes if it is on
$variable_name1 = trim( strip_tags( stripslashes( $POST['variable_name1'] ) ) );
$variable_name2= trim( strip_tags( stripslashes( $POST['variable_name2'] ) ) );
} else {
// no "magic_quotes_gpc"
// do not strip any slashes
$variable_name1= trim( strip_tags( $POST['variable_name1'] ) );
$variable_name2= trim( strip_tags( $POST['variable_name2'] ) );
}
Hope this helps you out. Someone else might have some better responses to your questions.