-2

I read that any variable declared after a namespace is then part of that namespace. I was confused then when reading about "URL variables":

<?php 
namespace OddTeaFlavors
return "
<nav>
<a href='index.php?flavor=acidRain'> Try Our new Acid Rain Flavor! </a>
</nav>
";

Would the URL variable flavor be part of the OddTeaFlavors namespace?

ridthyself
  • 821
  • 1
  • 8
  • 19

1 Answers1

2

There is no variable in that namespace, a string (which is data) is being returned. Once the data is out, you're no longer inside of that namespace. Once your HTML response gets sent, you're no longer even on the server.

Jeff Lambert
  • 24,395
  • 4
  • 69
  • 96
  • Thanks, I was thrown off by the term "URL variable", and wondered if a secret variable had been created behind the scenes. – ridthyself Apr 16 '15 at 19:04
  • Nope, it's variable in the context of the _browser_, but not when presented to PHP in the middle of a string – Jeff Lambert Apr 16 '15 at 19:45