When writing a string in single quotes, ensure that any apostrophes in the text do not prematurely terminate the string. To avoid this issue, either escape the apostrophes correctly or use double quotes for the string. This practice prevents syntax errors and maintains the integrity of the string.
1
2# Noncompliant: Apostrophe terminates the string prematurely, causing a syntax error.
3echo 'I can't believe it's not butter!'1
2# Compliant: Escaping the apostrophes allows them to be included in the single-quoted string.
3echo 'I can'\''t believe it'\''s not butter!'