I am surprised to see that the global variable does not need any initialization before it can be used in the program. Here's my small snippet which forced me to ask this question:
<?php
function set_variable()
{
global $name;
//$name = "admin";
}
set_variable();
?>
<input type="text" name="name" value="<?php echo $name; ?>" />
When this code is executed, it all works well. But if I don't make my variable name
as global then I see Undefined variable: name
in the textbox. Why does global make a huge difference?