使用file_get_contents两次使用变量

i am trying to use this bit of code to first retrieve a URL that is stored in a txt file on my server and save it as a variable, then run file_get_contents a second time using the URL i just retrieved and saved as a variable.

the code works for the first file_get_contents and echoes the URL that is stored, but fails to then use that URL in the second file_get_contents to echo the contents of the URL.

<?php
$files = file_get_contents('http://example.com/txtfile.txt');
echo $files;
$file = file_get_contents($files);
echo $file;
?>

Well the direct solution to your problem is:

<?php
    $files = file_get_contents('http://example.com/txtfile.txt');
    echo $files;

    $files = trim($files);

    $file = file_get_contents($files);
    echo $file;
?>

But this is huge security risk. Running file_get_contents to open a variable file is risky.