使用echo变量获取/显示外部URL上的文本

时间:2013-05-14 08:36:51

标签: php url variables

我在google上搜索如何通过php获取外部URL的文本,但我看到一个代码,它在网站上显示文本而不添加echo及其变量。如何使用php函数<?php echo $text; ?>在URL上显示文本。非常感谢!

2 个答案:

答案 0 :(得分:0)

您只需使用file_get_content()方法检索网址内容即可。

<?php
$text = file_get_contents('http://www.example.com/file.php');
echo $text;
?>

答案 1 :(得分:0)