-2

I have something like this

$var = <<<HEREDOC
..."request": ${"hello"}...
HEREDOC;

Of course PHP thinks ${"hello"} is a variable and it fails to load.

How to escape the $?

treyBake
  • 6,440
  • 6
  • 26
  • 57
prgrm
  • 3,734
  • 14
  • 40
  • 80

2 Answers2

6

The same way you escape almost anything in a string

$var = <<<HEREDOC
..."request": \${"hello"}...
HEREDOC;
echo $var;

RESULT

..."request": ${"hello"}...
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
2

Is that what you want?

$var = <<<HEREDOC
..."request": \${"hello"}...
HEREDOC;
Utopia
  • 663
  • 7
  • 8