I think you want a variables variable
In your case it would be:
$test = 1;
$t = 'test';
echo $$t;
// output: 1
Addon:
You could also do things like that:
$test['x'] = 1;
$t = 'test';
echo $$t['x'];
Whereas this will not work:
$test['x'] = 1;
$t = "test['x']";
echo $$t;
// Produces: NOTICE Undefined variable: test['x'] on line number 6
neither will:
$test = new stdClass();
$test->x = 1;
$t = "test->x";
echo $$t;
but this will work:
$test = new stdClass();
$test->x = 1;
$t = "{$test->x}";
echo $t;
and this will also work:
$test =[];
$test['x'] = 1;
$t = "{$test['x']}";
echo $t;