【发布时间】:2014-10-15 15:49:51
【问题描述】:
我刚开始使用 PHPStorm,但遇到了问题。
因此,当包含一个文件时,如果您在其中包含另一个文件,则路径无法正确理解。
例如 文件夹结构:
root/ Contains index.php
view/ Contains view.php
lib/ Contains functions.php
所以如果我在 index.php 中包含 view.php:
index.php:
include('view/view.php');
or
require('view/view.php');
运行此代码时,view.php 中的任何内容都包含在 index.php 中,因此 view.php 中包含的任何文件都相对于根目录。
view.php:
include('lib/functions.php');
但是 PHPStorm 认为它们是相对于视图目录的。
view.php:
include('../lib/functions.php');
在这种情况下他们不是。
这个问题也发生在类似的事情上:<a href="index.php">Link</a>
如何配置 PHPStorm 来应对这种情况?我以为它会自动解决这个问题,但目前不是。
具体例子:
private/
privatefile.php
public/
index.php
views/view1.php //Included in index.php
views/view2.php //Included in index.php
如果我想在 view1.php 中包含 privatefile.php,在这种情况下,'public' 会是资源根吗?
所以 view1.php 中的包含看起来像:include('../private/privatefile.php');
【问题讨论】:
标签: php file include directory phpstorm