The variable isn't available because you haven't defined it in the global scope.
The function "getmonth" has its own scope for variables and so if you define $mon in getmonth it can't be seen in any other scope.
function getmonth ($mo)
{
if($mo==01) { $mon=Jan;}
if($mo==02) { $mon=Feb;}
if($mo==03) { $mon=Mar; }
if($mo==04) { $mon=Apr; }
if($mo==05) { $mon=May; }
if($mo==06) { $mon=Jun; }
if($mo==07) { $mon=Jul; }
if($mo==08) { $mon=Aug; }
if($mo==09) { $mon=Sep; }
if($mo==10) { $mon=Oct; }
if($mo==11) { $mon=Nov; }
if($mo==12) { $mon=Dec; }
echo $mon; // This returns 'Nov' like it should.
return $mon;
}
$mo="11";
$mon = getmonth($mo); //ASSIGN $mon IN THIS SCOPE
echo $mon: // this is returning nothing so I tried the next line
echo isset( $mon); // this also returns nothing
Also, you really should put the month names in quotes and use proper indentation for the function 😛.
To help avoiding small errors such as this try putting "error_reporting(E_ALL);" at the top of your scripts. This shows up your error as a notice.
[edit] In response to YappyDog : globals are bad ... avoid them where possible