文件存在,但不会包含变量作为路径,不是权限问题

发布于 2024-12-11 15:13:59 字数 1920 浏览 0 评论 0原文

我正在开发一个模板,该模板可以生成由动态包含引入的动态内容。问题是,虽然这些包含文件存在(是的,我检查过),但它们不会包含或要求,并且即使有错误报告也不会抛出任何错误。这是相关的代码 - 请注意,我将其他文件包含在同一基目录中,没有任何问题,即 nav.php。

        <div id="main-wrap">
            <div id="main" role="main">
                <section id="header-img">
                     <div id="rotator">
                        <div id="controls">
                            <div id="rotator-next"></div>
                            <div id="rotator-prev"></div>
                        </div>
                        <img src="<?php echo $BD; ?>img/index-header.jpg" width="3416" height="362" alt="">
                    </div>
                    <?php
                        if ($PAGE !== 'step2')
                        {
                            require_once 'inc/form-main.php';
                        }
                    ?>
                </section><!-- /#header-img -->

                <div class="clear"></div>

                <div id="inner-page-content" class="wide locations">
                    <div id="inner-page-inner">
                        <?php
                            $path = "inc/pages/$service/$location.php";

                            echo $path . '<br>';

                            if (file_exists($path))
                            {
                                require_once "inc/pages/$service/$location.php";

                                echo '<pre>'; print_r(error_get_last()); echo '</pre>';
                            }
                            else
                            {
                                require_once 'inc/404w.php';
                            }

请注意,我尝试使用连接字符串,并尝试将 var 传递给 require $path。即使错误报告打开,也不会抛出任何工作和错误。当我回显 $path 时,它显示正确的路径。我已经检查了关联文件甚至目录的权限,它们都设置正确。

I have a template that I am working on that generates dynamic content pulled in by dynamic includes. The problem is that although these include files exist (yes I check), they won't include or require and throw no errors even with error reporting. Here's the relevant code - notice that I am including other files in the same base directory with no issues i.e. nav.php.

        <div id="main-wrap">
            <div id="main" role="main">
                <section id="header-img">
                     <div id="rotator">
                        <div id="controls">
                            <div id="rotator-next"></div>
                            <div id="rotator-prev"></div>
                        </div>
                        <img src="<?php echo $BD; ?>img/index-header.jpg" width="3416" height="362" alt="">
                    </div>
                    <?php
                        if ($PAGE !== 'step2')
                        {
                            require_once 'inc/form-main.php';
                        }
                    ?>
                </section><!-- /#header-img -->

                <div class="clear"></div>

                <div id="inner-page-content" class="wide locations">
                    <div id="inner-page-inner">
                        <?php
                            $path = "inc/pages/$service/$location.php";

                            echo $path . '<br>';

                            if (file_exists($path))
                            {
                                require_once "inc/pages/$service/$location.php";

                                echo '<pre>'; print_r(error_get_last()); echo '</pre>';
                            }
                            else
                            {
                                require_once 'inc/404w.php';
                            }

Notice that I have tried using a concatted string, and also tried passing a var to require $path. Neither work and no errors are being thrown even though error reporting on. When I echo $path out it shows the correct path. I've checked the perms on the associated files and even directories, and they are all set properly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

药祭#氼 2024-12-18 15:13:59

它可能与您的 PHP include_path 变量有关吗?该页面是否可能试图要求与当前工作目录相关的文件而不是来自站点根目录的文件?

Could it be related to your PHP include_path variable? Is the page perhaps trying to require the files in relevant to the current working directory rather than from the site root?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文