PHP Code:
<?php
$myName = "pein87";
function sayMyName()
{
echo $myName;
}
sayMyName();
?>
To get around this we can use global declaration in the function.
GLOBAL
This makes the variable global so it will use the value from a variable not defined in the function. This makes the variables scope global.
PHP Code:
<?php
$myName = "pein87";
function sayMyName()
{
global $myName;
echo $myName;
}
sayMyName();
?>
