Why does this code trigger an error? $string = ‘Shylock in a Shakespeare’s “Merchangt of Venice” demands his pound of flesh.’;

Advertisement

  • Strings should always be wrapped in double quotes; and double quotes inside a string should be escaped by backslashes.
  • All single and double quotes inside a string need to be escaped by backslashes to prevent a parse error.
  • The opening and closing single quotes should be replaced by double quotes; and the apostrophe should be escaped by a backslash.
  • The apostrophe needs to be escaped by a backslash to prevent it from being treated as the closing quote.
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Leave a Comment


Share via
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Send this to a friend