2012-02-21 96 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