有没有办法得到一个简单的php代码,只显示一个txt文档的文本,这是一个网址?
这就是我到目前为止所得到的。我肯定我错过了什么~
<?
$text = file_get_contents('https://dl.dropboxusercontent.com/u/28653637/Snip/Snip/Snip.txt');
fopen ($text)
?>我猜你打不开它,因为它不在硬盘上。有什么变通的办法,或者你们能帮我解决的问题吗?
谢谢(:
发布于 2013-05-22 03:37:52
太简单了!:)
$text = file_get_contents('https://dl.dropboxusercontent.com/u/28653637/Snip/Snip/Snip.txt');
echo $text;解释:
file_get_contents()将返回远程文件的内容,并将其赋给$text变量。然后,您只需使用echo语句输出这些内容
替代:使用readfile()函数。它将直接输出文件的内容:
readfile('https://dl.dropboxusercontent.com/u/28653637/Snip/Snip/Snip.txt');发布于 2013-05-22 03:39:07
你不需要打开它。它已经作为字符串附加到变量$text中。
$text = file_get_contents('https://dl.dropboxusercontent.com/u/28653637/Snip/Snip/Snip.txt');
echo $text;
//Outputs "“Why Don't You Get A Job?” ― The Offspring"https://stackoverflow.com/questions/16678095
复制相似问题