If your print or echo statements begin with double-quotes then you have to escape any double-quotes in your string. If they begin with single-quotes, then you have to escape your single-quotes in your string. Make sense?
example1:
print "John said, \"I know how to do it\"";
example2:
print 'These are the contents of John\'s string';
If you are using double-quotes to surround your string and you have single-quotes in the string, they do not need to be escaped and vice versa.