$str: " ' \ 

addcslashes($str,"\\\'\"\n\r"):   
\" \' \\ \n\r