 <p>A global variable declared outside function cannot be accessed inside the function try declaring global iinside the function itself.</p> <p>Change it to this</p> <pre><code>function kit($name) { global $foo; if($foo == $name){echo 'Works';}else{echo 'Does not work';} } </code></pre>