You would call it from a plugin, you can not execute PHP code in a template (HTML).
There is no "CGI variable". They are just simple PHP variables as used anywhere in a PHP-script.
Consider the following 2 scripts:
Main script "test.php"
PHP Code:
<?php
// Main test script test.php
$mainvar = "local set in test.php";
include('./sub.php');
echo "<br />test.php: Var set in sub: " . $subvar;
?>
And the 2nd script "sub.php" (store in the same directory as test.php):
PHP Code:
<?php
// sub.php
echo "<br />sub.php: Value for \$mainvar: " . $mainvar;
global $subvar;
$subvar = "This value was set in sub";
?>
Now point your browser to test.php.
You will see that the variable $mainvar that was set in "test.php" is also available in "sub.php" without any variable passing or such. The same goes for $subvar, set in sub.php and still available when returning in test.php.