0

This works:

Welcome <?php echo $_GET["name"]; ?><br>

But this doesn't:

'html' => 'Hello $_GET["name"];',

How should I code this?

Jay Blanchard
  • 33,530
  • 16
  • 73
  • 113
finisterre
  • 331
  • 7
  • 17
  • Is this in a .php file ? Perhaps the file you edited is not mapped to be processed by php, usually this is done for each extension. – Marged Jun 11 '15 at 16:19

2 Answers2

-1

it should be echo "Hello $_GET['name']";, single quotes show exact values, you can use double quotes if you are using variables.

kamal pal
  • 4,119
  • 5
  • 24
  • 39
-1
echo "Hello {$_GET["name"]}";

This should do.

Correction: Its not a good practice to use double quotes inside double quotes as pointed out in comments. So the correct thing should be Hello {$_GET['name']}

Rash
  • 7,007
  • 1
  • 47
  • 68
  • The syntax highlighting here on SO should show you there's a problem with your answer.... double quotes inside double quotes isn't a good idea – Mark Baker Jun 11 '15 at 16:23
  • @MarkBaker How so..I am running this exact line in my server right now. I dont see any error. – Rash Jun 11 '15 at 16:24
  • @MarkBaker Oh yeah! Its not a good idea..but its not an error. but you are right. Better follow the guidelines – Rash Jun 11 '15 at 16:25
  • @MarkBaker Nope. Here is my code – Rash Jun 11 '15 at 16:26
  • it's not an error, but it looks so very WRONG... and undoes all the other Q/A's here that say, basically, "don't use the same quotes inside a string as you used to enclose the string" – Marc B Jun 11 '15 at 16:37