我安装了Mail_Mime包。
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
这2个文件肯定在文件夹中:
/usr/lib/php/PEAR/Mail.php
/usr/lib/php/PEAR/Mail/mime.php
pear list告诉我所需的软件包已安装且没有遗漏的依赖项
答案 0 :(得分:7)
是否在您的包含路径中?
var_dump(get_include_path());
如果不是,请尝试手动添加此内容以将其添加到包含路径:
在运行时:
$path = get_include_path() . PATH_SEPARATOR . '/usr/lib/php/PEAR';
set_include_path($path);
或者在php.ini中
include_path=".:--Whatever's here already--:/usr/lib/php/PEAR"
另一方面,如果您关心它被包含在内,为什么不使用require_once?它会阻止它被多次包含(_once部分)并导致致命错误。如果无法找到代码,它还会阻止执行其余的代码......
答案 1 :(得分:1)
对于使用虚拟主机的Plesk用户:不要忘记将目录指令包含在 /var/www/vhosts/yourdomain/subdomains/yoursubdomain/conf/vhost.conf中的vhost.conf中当你设置open_basedir以允许包含PEAR库
时<Directory /var/www/vhosts/yourdomain/subdomains/yoursubdomain/httpdocs>
<IfModule mod_php4.c>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value open_basedir "/var/www/vhosts/yourdomain/subdomains/yoursubdomain/httpdocs:/tmp:/usr/share/php"
</IfModule>
<IfModule mod_php5.c>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value open_basedir "var/www/vhosts/yourdomain/subdomains/yoursubdomain/httpdocs:/tmp:/usr/share/php"
</IfModule>
Options -Includes -ExecCGI
</Directory>