0

I'm trying to add " " on a php variable,

What i have:

$id = 123;
echo "{$id}"; //123 

How can i return "123" instead of just 123?

echo ""{$id}""; //adding extra columns is not working
remy boys
  • 2,928
  • 5
  • 36
  • 65

1 Answers1

4

You escape the double quotes you want in the string with the \ backslash, like this:

$id = 123;
echo "\"{$id}\""; 
KIKO Software
  • 15,283
  • 3
  • 18
  • 33
  • Yes, I agree, this question has been asked before, but so have most other questions. This is however a very basic one, and doing only a bit of research would have retrieved the answer. See: https://stackoverflow.com/help/how-to-ask – KIKO Software Jul 25 '18 at 19:57