[英]using file_get_contents twice with a variable
我試圖使用這段代碼來首先檢索存儲在服務器上txt文件中的URL並將其另存為變量,然后使用剛剛檢索並另存為變量的URL再次運行file_get_contents。
該代碼適用於第一個file_get_contents並回顯所存儲的URL,但隨后無法使用第二個file_get_contents中的URL來回顯URL的內容。
<?php
$files = file_get_contents('http://example.com/txtfile.txt');
echo $files;
$file = file_get_contents($files);
echo $file;
?>
那么,直接解決您的問題的方法是:
<?php
$files = file_get_contents('http://example.com/txtfile.txt');
echo $files;
$files = trim($files);
$file = file_get_contents($files);
echo $file;
?>
但這是巨大的安全風險。 運行file_get_contents來打開變量文件是有風險的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.