调用require_once()时出现警告和致命错误 [英] Warning and Fatal error calling require_once()

查看:1934
本文介绍了调用require_once()时出现警告和致命错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从其他网站获取div元素。

I want to fetch div element from other website .

iam拥有我的个人资料,我尝试使用此代码。

on which iam having my profile, i have tried using this code.

require_once('../simple_html_dom.php');

$html=file_get_html('http://www.example.com');
$ret=$html->find("div[id=frame-gallery]");
$ret=array_shift($ret);
echo($ret);

但此代码出错


警告:
require_once(../ simple_html_dom.php)
[function.require-once]:未能
开放流:没有这样的文件或目录

中的$ b:第22行的$ \ wamp \\\ in.com \ components \ com_content \ view.php

Warning: require_once(../simple_html_dom.php) [function.require-once]: failed to open stream: No such file or directory in E:\wamp\www\in.com\components\com_content\view.php on line 22

致命错误:require_once()
[function.require]:无法打开
必需'../simple_html_dom.php'
(include_path ='.; ./ includes; ./梨')
in
E:\ wamp\www \in.com \ components\com_content\view.php
22行

Fatal error: require_once() [function.require]: Failed opening required '../simple_html_dom.php' (include_path='.;./includes;./pear') in E:\wamp\www\in.com\components\com_content\view.php on line 22

iam坚持使用这个plz帮我处理从网站上获取特定div元素的代码片段

iam stuck with this plz help me with the code snippets for fetching the specific div element from a website

推荐答案

文件 simple_html_dom.php 不是你告诉PHP要查找的地方。

The file simple_html_dom.php is not where you're telling PHP to look for it.

require_once('../simple_html_dom.php');

为安全起见,请尝试使用完整路径而不是相对路径。

To be safe, try using the full path instead of a relative path.

require_once('E:\wamp\www\in.com\components\simple_html_dom.php');

BTW,如果上面的完整路径不正确,那么这就是你的问题。这是PHP正在尝试的路径。

BTW, if the full path above is incorrect, then that is your problem. This is the path that PHP is trying.

澄清:我只是建议OP切换到绝对路径来识别和确认问题的根源。以绝对路径进行生产很少是一个好主意。

To clarify: I'm only suggesting the OP switch to absolute paths to identify and confirm the source of the issue. Going to production with absolute paths is rarely a good idea.

这篇关于调用require_once()时出现警告和致命错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆