2012-02-21 63 views
0

我做了什麼:問題用PHP斯威夫特梅勒

  1. )下載斯威夫特-4.1.5.tar
  2. )提取其
  3. )上傳到我的/的public_html /域/ lib目錄主機使用FileZilla
  4. )使用下面的代碼創建了一個新腳本。
  5. )打開它在瀏覽器中,我得到了下面

以下錯誤所以我的問題是,如何我收到,如果它是100%有文件不存在錯誤?謝謝!

<?php 

     require_once '/public_html/domain/lib/swift_required.php'; 

    ?> 

警告:require_once(/public_html/domain/lib/swift_required.php)一次function.require-]:未能打開流:在/ home/myuser的/的public_html /域沒有這樣的文件或目錄/ email.php第5行

致命錯誤:require_once()[function.require]:無法開口所需 '/public_html/domain/lib/swift_required.php'(include_path中=」:/ usr/lib中/ PHP的:/usr/local/lib/php')在第5行的/home/myuser/public_html/domain/email.php

下面是我的FileZilla目錄的屏幕截圖。 http://i.imgur.com/Zsy8y.jpg

+0

通過用斜槓啓動路徑,您可以指定從系統根目錄開始的絕對路徑。你的filezilla只顯示一個相對於你的服務器文檔根目錄的路徑。 – Basti 2012-02-21 18:52:30

回答

2

這是錯誤的:

// this is absolute path, just like /home/user or /var/www 
require_once '/public_html/domain/lib/swift_required.php'; 

使用,而不是:

// this is relative path to the current file 
require_once 'public_html/domain/lib/swift_required.php'; //notice: no '/' in the beggining 

OR:

// so use this one if you know the whole path to the file 
require_once ABSOLUTE_PATH_TO . 'public_html/domain/lib/swift_required.php'; 

OR:

// or use this one if you don't know the whole path 
// or if the path will change (dev machine and production machine) 
require_once dirname(__FILE__) . RELATIVE_PATH_TO . 'public_html/domain/lib/swift_required.php'; 
+0

這很奇怪,但即使沒有反斜槓,它也不會起作用。我通過使用'lib/swift_required.php'來修復它,我會在5分鐘內接受你的答案,謝謝。 – user1224096 2012-02-21 18:54:38

+0

其真實的文件位置你調用它,總是使用絕對路徑是一個好主意。 – 2012-02-21 18:59:04