PHP 获取另一个 php 页面的内容
PHP Get content of another php page
我有一个显示此内容的网页:http://i.imgur.com/QUkMoiC.jpg
只是纯文本。我需要将其包含在另一个 php 网页中,例如
$string = include('http://77.144.233.158:4032/currentsong?sid=1');
echo $string;
所以这可以 return "King crimson - Moonchild - Lyrics"。
但这不起作用。
我该怎么办?
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() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.
我有一个显示此内容的网页:http://i.imgur.com/QUkMoiC.jpg 只是纯文本。我需要将其包含在另一个 php 网页中,例如
$string = include('http://77.144.233.158:4032/currentsong?sid=1');
echo $string;
所以这可以 return "King crimson - Moonchild - Lyrics"。 但这不起作用。
我该怎么办?
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() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.