I have a pure PHP script - no frameworks, no OOP - like this:
<?php
define('VAR1', 'xxxxxxxxxx');
define('VAR2', 'xxxxxxxxxx');
define('VAR3', 'xxxxxxxxxx');
function myFunction()
{
// I need to access VAR1, VAR2, VAR3 here
}
$output = myFunction();
How do I access VAR1
,VAR2
and VAR3
inside myFunction()
? By declaring them as GLOBAL
inside the function?
The scope of a constant is already global, so just use them as they are: