LinkedIn PHP Skill Quiz Assessment Answers

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

Latest Update on 29th December, 2021 by Certification Course Answers

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

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

Correct Answer:

  • The apostrophe needs to be escaped by a backslash to prevent it from being treated as the closing quote.

Latest Updates

No posts found in this category.