【发布时间】:2017-07-29 17:49:05
【问题描述】:
我正在尝试在我的本地主机上学习 HTML DOM 解析。但我一开始就崩溃了。
1) 我做了一个新项目
2) 我从simplehtmldom.sourceforge.net下载了文件
3) 我已将此代码放入我的 HTML 项目中
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
// put your code here
$html = file_get_html('http://www.google.com/');
?>
</body>
</html>
4) 运行脚本时出现此错误:
致命错误:未捕获的错误:调用 C:\xampp\htdocs\PhpProject1\index.php:15 中未定义的函数 file_get_html() 堆栈跟踪:#0 {main} 在 C:\xampp\htdocs\PhpProject1\ 中抛出第 15 行的 index.php
我是不是误会了什么?
【问题讨论】:
-
你需要使用DOM解析器。详情here
-
@AshiqurRahman 我已经下载了这些文件并将它们放在我的项目文件夹中
-
您需要在 HTML 代码中包含 DOM 解析器 PHP 库文件。
-
你必须下载并包含php dom解析器
https://sourceforge.net/projects/simplehtmldom/files/
标签: php html parsing sourceforge