Codeigniter:调用非对象上的成员函数 item()
我在本地安装了Codeigniter 2.1.0,效果很好。
但是,当我将其上传到我的提供商时,我首先得到:
您的系统文件夹路径似乎设置不正确。请打开以下文件并更正此问题:index.php
我可以通过将index.php: 更改
$system_path = "system";
$application_folder = "application";
为(为什么?我从来没有这样做过...)
$system_path = dirname(__FILE__) . "/system";
$application_folder = dirname(__FILE__) . "/application";
来解决此问题,但随后我得到:
致命错误:在第 47 行
我可以注释掉该行,但随后在其他地方遇到类似的错误。
请问,这是我的提供商的问题吗?或者我做错了什么?我之前使用过 CI,它在其他地方运行得非常完美。
PS:请注意,这是 CI 的全新安装。
I have installed Codeigniter 2.1.0 locally, it works great.
But when I upload it to my provider I first get:
Your system folder path does not appear to be set correctly. Please open the following file and correct this: index.php
I can fix this by changing index.php:
$system_path = "system";
$application_folder = "application";
to (why? I never had to do this...)
$system_path = dirname(__FILE__) . "/system";
$application_folder = dirname(__FILE__) . "/application";
But then I get:
Fatal error: Call to a member function item() on a non-object in <path>/Utf8.php on line 47
I can comment out the line but I then get similar error somewhere else.
Please, is this problem at my provider? Or am I doing something wrong? I used CI before and it worked elsewhere flawlessly.
PS: Please not this is completely fresh install of CI.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是与否,
问题是您的提供商的网络服务器设置可能与您不同。如果他这样做,您必须调整设置以满足需要。
造成这个问题的主要原因是文件系统中表达路径的样式多种多样。 *NIX 系统使用正斜杠来表达文件夹结构。在 Windows 机器上它是反斜杠。
*NIX 系统的文件系统根目录为“/”,Windows 机器的根目录为 C:/、D:/ 等...
每个文件系统都有不同的访问权限设置及其管理。
在大多数 UNIX 系统上,可以毫无问题地定位路径。因此,如果 codeigniter 尝试从“所谓的”相对目录中确定 CI 所在目录的绝对路径,他就会成功。如果没有,它就无法工作,因为他不知道它要加载的文件在哪里。
PHP 版本之间也存在许多错误。例如。据报道,PHP 5.2.0 和 Windows Apache 存在错误(对目录具有某些权限),即使目录存在,is_dir() 函数也会返回 False,并且它应该(并且在其他系统上将)返回 True。
确保正确加载路径的最确定方法是提供 CI 绝对路径。绝对路径因操作系统而异,例如。在 UNIX 上是 /var/www/domain.com/system,在 Windows 上“谁知道?”。但有一种方法可以轻松确定它。
在根文件夹中创建 index.php 文件,您可以访问其中的内容:
如果您加载页面,将会(除其他外)在行中说明绝对路径:
现在如果您将分配$system_path 变量的绝对路径应该足够了。为了获得更大的确定性,还可以分配 $application_folder 变量。
请注意,系统文件夹的路径必须是 code igniter 的 system 文件夹,应用程序文件夹的路径必须是 application 文件夹。例如:
之后您的网站应该可以完美运行。
(用户指南中对此有一些提及:http://ellislab.com/ codeigniter/user-guide/installation/index.html)
Yes and no,
the problem is that your provider has probably different web server settings than you do. If he does, you have to adapt the settings, that fits the needs.
The main root cause of this problem is the variety of styles that can express path in the file system. *NIX systems uses forward-slash for expressing folder structure. On Windows machines its a back-slash.
The *NIX systems have root of the file system "/", Windows machines has C:/, D:/ etc...
Every file system has different settings of access rights and their management.
On most of the UNIX systems works locating of the path without a trouble. So if codeigniter tries to determine absolute path of the directory where is CI located, from the "so called" relative directory, he will succeed. If not, it can't work because he don't know where are the files it wants to load.
There are also many bugs across the PHP versions. Eg. there is reported bug with PHP 5.2.0 and Windows Apache that (with certain rights on the directory) the is_dir() function returns False even if the directory is present and it should (and on the other system will) return True.
The most certain way to ensure the path is loaded correctly is to give the CI absolute path. The absolute path varies on OS and eg. on UNIX is /var/www/domain.com/system, on Windows "who knows?". But there is a way how to determine it easily.
Create index.php file in the root folder you can access with this content inside:
If you load the page there will be (among other things) stated the absolute path in row with:
Now if you will assign the absolute path to the $system_path variable it should be sufficient. For greater certainty also assign $application_folder variable.
Note that the path to system folder has to be to the system folder of code igniter and path to application folder has to be to the application folder. So for example:
After that your site should work flawlessly.
(there are some mentions about this on user guide: http://ellislab.com/codeigniter/user-guide/installation/index.html)