Why would the code below ouput hello when it shouldn't? It's as if it's setting $test='hello' before any of the checks. Is there any reason this could be happening? This is a small piece of code from a bigger script but I'm not using $test anywhere outside of this code, even in other includes etc. Code: if (isset($test)){echo test;} if (!isset($test)){ $test='hello'; }
Hi, Which version of PHP are you using? It would be more helpful if you pasted your entire code... although as much as you protest, it would appear that $test is being set in the global scope somewhere. Put this before your code snippet and reply with the output: PHP: var_dump($test);exit();
ugh it's my fault, you're right, the code was in a file that I didn't realise was being included multiple times in a loop.