The $custnum is fine the way you have it. I believe some older versions of PHP required the keyword "global" here, but not anymore (not sure).
The important thing is, you must also redeclare this variable inside of each function declaration as :
function1()
{
global $custnum;
$custnum = somevalue;
}
Otherwise, your function will be working with a local variable, NOT the global one. PHP functions, unlike C++, do not see these global variables unless you declare them as such inside the function.