I think $domain is defined in settings.php, right ?
I would not include the settings.php to the function scope using include_once(). Maybe include() would work, but I would not do that either.
Move your include_once to the very top of the script (to the global scope from the function scope). And then
- either add
to your functions (not recommended)
- or add $domain as a parameter to the functions (exactly as Fou-Lu said)
- or (I would follow this way) define your domain as a constant
in the configuration file and use it anywhere you need (constant would be available in any scope after it is defined and you would need your domain in more than one place in your system most probably).