<?php

function debug($var_name, $scope_vars=null) {
    if ($scope_vars === null) {
        $scope_vars = $GLOBALS;
    };
    printf('%s value is %s', $var_name, var_export($scope_vars[$var_name], true));
}

$testvar1 = 'ABCDEF';
debug('testvar1');

echo PHP_EOL;

function testfunc2() {
    $testvar2 = 'GHIJKL';
    debug('testvar2', get_defined_vars());
}
testfunc2();
