不能包含肯定存在(并已安装)的 pear 包 [英] Can't include pear package that definitely exists (and is installed)

查看:40
本文介绍了不能包含肯定存在(并已安装)的 pear 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了 Mail_Mime 包.

I installed the Mail_Mime package.

include('Mail.php');
include('Mail/mime.php');

我收到以下错误:

Warning: include(Mail.php) [function.include]: failed to open stream: No such file or directory in /var/www/vhosts/domain.co.uk/httpdocs/mail_mime/index.php  on line 2

Warning: include() [function.include]: Failed opening 'Mail.php' for inclusion (include_path='.:/usr/lib/php/PEAR:/usr/lib/php/modules') in /var/www/vhosts/domain.co.uk/httpdocs/mail_mime/index.php on line 2

Warning: include(Mail/mime.php) [function.include]: failed to open stream: No such file or directory in /var/www/vhosts/domain.co.uk/httpdocs/mail_mime/index.php on line 3

Warning: include() [function.include]: Failed opening 'Mail/mime.php' for inclusion (include_path='.:/usr/lib/php/PEAR:/usr/lib/php/modules') in /var/www/vhosts/domain.co.uk/httpdocs/mail_mime/index.php on line 3

这两个文件肯定在文件夹中:

the 2 files are definitely in the folders:

/usr/lib/php/PEAR/Mail.php
/usr/lib/php/PEAR/Mail/mime.php

pear list 告诉我所需的包已经安装,并且没有缺少依赖项

pear list tells me that the packages required are installed and there are no missing dependencies

推荐答案

是否在你的包含路径中?

Is it in your include path?

var_dump(get_include_path());

如果不是,请尝试预先添加它以将其添加到包含路径:

If it's not, try adding this before hand to add it to the include path:

在运行时:

$path = get_include_path() . PATH_SEPARATOR . '/usr/lib/php/PEAR';
set_include_path($path);

或者在 php.ini 中

Or in php.ini

include_path=".:--Whatever's here already--:/usr/lib/php/PEAR"

顺便说一句,如果您关心它被包含在内,为什么不使用 require_once 呢?它将防止它被多次包含(_once 部分)并导致致命错误.如果找不到,它还会阻止执行其余代码...

On a side note, if you care about it being included, why not use require_once? It'll prevent it from being included multiple times (the _once part) and causing a fatal error. It'll also prevent the execution of the rest of the code if it can't be found...

这篇关于不能包含肯定存在(并已安装)的 pear 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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