-1

I hava a problem at my PHP script!
I want to do something like

echo "hello $var";

And the output should be "hello $var". So it should not take the value of $var, but a string "$var".
I want to use this to create a php file with a php script...

Is there any way to solve this?
Thanks in advance!

Jonathan
  • 71
  • 1
  • 9
  • 3
    `echo 'hello $var';` - no answer required. – Funk Forty Niner Oct 21 '14 at 19:19
  • https://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php and [php.net strings](https://secure.php.net/manual/en/language.types.string.php) explain the difference between single and double quoted strings – rbassett Mar 18 '19 at 11:24

1 Answers1

2

Use single quotes:

echo 'hello $var';

Or escape the $:

echo "hello \$var";
AbraCadaver
  • 78,200
  • 7
  • 66
  • 87
kainaw
  • 4,256
  • 1
  • 18
  • 38