Php 使用文件获取内容来抓取站点,然后删除标题并显示站点?
在下面的代码中,我尝试使用file get contents命令获取网站内容并将其输出,但在运行它时,它会显示一个空白页面Php 使用文件获取内容来抓取站点,然后删除标题并显示站点?,php,file-get-contents,Php,File Get Contents,在下面的代码中,我尝试使用file get contents命令获取网站内容并将其输出,但在运行它时,它会显示一个空白页面 <html> <?php $site = "http://facebook.com"; echo $file_get_contents[$site]; ?> <html> 或者类似于编辑标题,但显示网页的第一个代码不起作用,那么会出现什么错误?这可能会起作用,但我想它需要某种SSL或其他东西,请参阅更多关于 file_get_c
<html>
<?php
$site = "http://facebook.com";
echo $file_get_contents[$site];
?>
<html>
或者类似于编辑标题,但显示网页的第一个代码不起作用,那么会出现什么错误?这可能会起作用,但我想它需要某种SSL或其他东西,请参阅更多关于 file_get_contents()-将整个文件读入字符串 因为它是一个函数,而不是代码中使用的数组
<?php
$site = "http://facebook.com";
echo file_get_contents($site); // remove $ from file_get_contents() function
?>
正确用法是
文件获取内容()
。这是一个函数-您将其作为哈希变量调用。只是语法问题。请参阅下面的正确用法:
<html>
<?php
$site = "http://facebook.com";
echo file_get_contents($site);
?>
<html>
阅读文件获取内容文档了解更多信息:要更改的两点。
1.删除文件_get_content()前面的$,因为它是一个函数。
2.由于这是一个函数,参数是使用()而不是[]馈送的,这意味着一个数组,下次请尝试将错误消息发布到,这将有助于快速发现代码中的问题
<html>
<?php
$site = "http://facebook.com";
echo file_get_contents($site);
?>
<html>
标题('X-Frame-Options:GOFORIT')
将允许您根据需要将页面加载到iframe中**$**文件\u获取\u内容?这可能是一个输入错误,他?在我看来,你是在回显一个数组值,而不是调用一个函数。
<html>
<?php
$site = "http://facebook.com";
echo file_get_contents($site);
?>
<html>