2012-07-25 49 views
0

打开流我一个简单的方法include得到这个错误:在使用本未能在PHP

Warning: include(/home/content/70/8352870/html/sites/mysite.com/preview/wp-content/themes/site-theme/mail/class.phpmailer.php) 
[<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /home/content/70/8352870/html/sites/mysite.com/preview/wp-content/themes/site-theme/mail/send-message.php on line 5 

我已经包含在文件:

<?php 
    $path = getcwd(); 
    include $path.'/class.phpmailer.php'; 
?> 

我得到了同样的错误,而无需使用getcwd方法但这:

include 'class.phpmailer.php'; 

Warning: include(class.phpmailer.php) 
[<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /home/content/70/8352870/html/sites/mysite.com/preview/wp-content/themes/site-theme/mail/send-message.php on line 10 

Obiouvsly我检查的文件位于这里:

mysite.com/preview/wp-content/themes/site-theme/mail/ 
class.phpmailer.php 
class.pop3.php 
class.smtp.php 
send-message.php 

我做错了什么?

+1

'class.phpmailer.php'肯定在'/ home/content/70/8352870/html/sites/mysite.com/preview/wp-content/themes/site-theme/mail'中? – DaveRandom 2012-07-25 14:40:28

+0

你可以显示'print_r(glob(getcwd()。'/ *。php'));' – DaveRandom 2012-07-25 14:41:41

+0

对,我会再次检查,我正在使用尾波并且有时候会制造诡计 – vitto 2012-07-25 14:41:47

回答

0

这有您想获得相同的行为,但更值得信赖:

(我假设class.phpmailer相同路径上的是包括它的脚本)

<?php 
$path = dirname(__FILE__); 
include $path.'/class.phpmailer.php'; 
?> 
+0

FYI,自5.3'__DIR__ == = dirname(__FILE__)'。和'getcwd()'都不相同,因为当前工作目录不一定是当前脚本的位置。 – DaveRandom 2012-07-25 14:45:39