在 cakephp 中包含文件
我要生气了。我不明白有什么问题。 显然我正在尝试 require_once() 但它不起作用。如您所见,该文件应该位于正确的位置。任何人都知道为什么它不起作用?
I'm getting mad. I can't understand what's the problem.
Obviously i'm trying a require_once() but it doesn't work. As you can see, the file should be in the right place. Anyone have a clue why it doesn't work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您的供应商文件夹中有一个文件(即vendors/filename.php),
您可以执行以下操作:
这里有更多示例 包括供应商
If you have a file in your vendors folder (i.e., vendors/filename.php)
You can do:
Here's some more examples of including vendors
您可以通过不同的方式包含文件:
http://book.cakephp.org/2.0/en/core -utility-libraries/app.html
在您的情况下,您使用 Lucene 作为供应商,因此正确的包含内容是:
加载 /app/Vendor/lucene/Search/Lucene .php
You can include files in different ways:
http://book.cakephp.org/2.0/en/core-utility-libraries/app.html
In your case you're using Lucene as a vendor, so the correct include would be:
to load /app/Vendor/lucene/Search/Lucene.php
只需适当放置您的路径即可。例如
require_once('/cake/importedfolder/imported_file.php');
只要您的 .htaccess 设置为具有权限并且启用了 mod_rewriting 即可。
为了更好地叙述:您可以将包含要导入的文件的文件或文件夹放在“webroot”文件夹中
例如,我们需要一个connection.php 文件(只是为了解释)。
您所要做的就是将文件放在“webroot”中
然后要求它。 :因此 'require_once(/cake/connection.php');
让我知道这是否有帮助......
Just place your path appropiately. For instance
require_once('/cake/importedfolder/imported_file.php');
In as much as your .htaccess is set to have permission and mod_rewriting is enabled.
To narrate better: you can place the file or folder containing the file you want to import in the 'webroot' folder
For instance we want to require a connection.php file (just to explain tho).
All you have to do is place the file in 'webroot'
And then require it. : thus 'require_once(/cake/connection.php');
Let me know if this helps.....