title: PHP: How to assign large string with single and double quotes
body: <p>I need to assign large strings in an array. These strings contain single and double quotes as well as backslashes which <strong><em>cannot</em></strong> be escaped at first.</p>
  
  <p>My code looks like: </p>
  
  <pre><code>$myArray = [
      'x' =&gt; 'this_is_my_string',
  ];
  </code></pre>
  
  <p>Now instead of <code>'this_is_my_string'</code> I have large strings as:</p>
  
  <pre><code>\relative c' {
      \key ees \major
      bes'2 \mf c   bes4. (as8) g4 (as) \breathe
      \bar "|."
  </code></pre>
  
  <p>How to write my code to directly assign large strings like this one?</p>
  
  <p>I have tried with <a href="https://www.php.net/manual/de/language.types.string.php#language.types.string.syntax.heredoc" rel="nofollow noreferrer">HEREDOC</a> and <a href="https://www.php.net/manual/de/language.types.string.php#language.types.string.syntax.nowdoc" rel="nofollow noreferrer">NOWDOC</a> and <a href="https://www.php.net/manual/de/function.addslashes" rel="nofollow noreferrer">addslashes</a>/<a href="https://www.php.net/manual/de/function.addcslashes.php" rel="nofollow noreferrer">addcslashed</a> but they require to escape at least one of <code>´</code>or <code>"</code>.</p>
  
  <p>BTW: the large strings are <a href="http://lilypond.org" rel="nofollow noreferrer">Lilypond</a> snippets</p>