2012-07-25 29 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