【问题标题】:PHP Get content of another php pagePHP 获取另一个 php 页面的内容
【发布时间】:2016-08-05 20:45:15
【问题描述】:
我有一个网页显示这个:http://i.imgur.com/QUkMoiC.jpg
只是纯文本。我需要将其包含在另一个 php 网页中,例如
$string = include('http://77.144.233.158:4032/currentsong?sid=1');
echo $string;
所以这可以返回“King crimson - Moonchild - Lyrics”。
但这不起作用。
我该怎么办?
【问题讨论】:
标签:
php
html
include
shoutcast
【解决方案1】:
Include 将评估指定文件中的内容(并将其作为 PHP 运行)。例如,如果您有:
$str = 'King crimson - Moonchild - Lyrics';
您可以包含它,然后回显$str 以获取您要查找的内容。
我想你要找的是file_get_contents():
$string = file_get_contents('http://77.144.233.158:4032/currentsong?sid=1');
echo $string;
来自文档:
file_get_contents() 是将文件内容读入字符串的首选方法。如果您的操作系统支持,它将使用内存映射技术来提高性能。