Search code examples
phpnamespacesurlvariables

PHP: are URL variables in the namespace they were declared?


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?


Solution

  • 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.