<small id='FqGle'></small><noframes id='FqGle'>

    • <bdo id='FqGle'></bdo><ul id='FqGle'></ul>
    <legend id='FqGle'><style id='FqGle'><dir id='FqGle'><q id='FqGle'></q></dir></style></legend>
    <i id='FqGle'><tr id='FqGle'><dt id='FqGle'><q id='FqGle'><span id='FqGle'><b id='FqGle'><form id='FqGle'><ins id='FqGle'></ins><ul id='FqGle'></ul><sub id='FqGle'></sub></form><legend id='FqGle'></legend><bdo id='FqGle'><pre id='FqGle'><center id='FqGle'></center></pre></bdo></b><th id='FqGle'></th></span></q></dt></tr></i><div id='FqGle'><tfoot id='FqGle'></tfoot><dl id='FqGle'><fieldset id='FqGle'></fieldset></dl></div>
    <tfoot id='FqGle'></tfoot>

    1. 如何找到应用程序的基本网址?

      时间:2023-10-03
    2. <small id='GtrRy'></small><noframes id='GtrRy'>

    3. <legend id='GtrRy'><style id='GtrRy'><dir id='GtrRy'><q id='GtrRy'></q></dir></style></legend>
        <i id='GtrRy'><tr id='GtrRy'><dt id='GtrRy'><q id='GtrRy'><span id='GtrRy'><b id='GtrRy'><form id='GtrRy'><ins id='GtrRy'></ins><ul id='GtrRy'></ul><sub id='GtrRy'></sub></form><legend id='GtrRy'></legend><bdo id='GtrRy'><pre id='GtrRy'><center id='GtrRy'></center></pre></bdo></b><th id='GtrRy'></th></span></q></dt></tr></i><div id='GtrRy'><tfoot id='GtrRy'></tfoot><dl id='GtrRy'><fieldset id='GtrRy'></fieldset></dl></div>

            <tbody id='GtrRy'></tbody>

            • <tfoot id='GtrRy'></tfoot>

                <bdo id='GtrRy'></bdo><ul id='GtrRy'></ul>
                本文介绍了如何找到应用程序的基本网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我想找到我的应用程序的基本 url,以便我可以自动引用我的应用程序树中的其他文件...

                I'd like to find the base url of my application, so I can automatically reference other files in my application tree...

                因此,在我的应用程序的基础中给定一个文件 config.php,如果子目录中的文件包含它,则知道在 url 前添加什么前缀.

                So given a file config.php in the base of my application, if a file in a subdirectory includes it, knows what to prefix a url with.

                application/config.php
                application/admin/something.php
                application/css/style.css
                

                因此,鉴于访问了 http://www.example.com/application/admin/something.php,我希望它能够知道 css 文件在 中$approot/css/style.css.在这种情况下,$approot/application",但我希望它知道该应用程序是否安装在其他地方.

                So given that http://www.example.com/application/admin/something.php is accessed, I want it to be able to know that the css file is in $approot/css/style.css. In this case, $approot is "/application" but I'd like it to know if the application is installed elsewhere.

                我不确定这是否可能,许多应用程序(我认为是 phpMyAdmin、Squirrelmail)必须首先设置一个配置变量.如果它只是知道它会更加用户友好.

                I'm not sure if it's possible, many applications (phpMyAdmin, Squirrelmail I think) have to set a config variable to begin with. It would be more user friendly if it just knew.

                推荐答案

                我在 homebrew 框架中使用以下内容...将其放在应用程序根文件夹中的文件中并简单地包含它.

                I use the following in a homebrew framework... Put this in a file in the root folder of your application and simply include it.

                define('ABSPATH', str_replace('\', '/', dirname(__FILE__)) . '/');
                
                $tempPath1 = explode('/', str_replace('\', '/', dirname($_SERVER['SCRIPT_FILENAME'])));
                $tempPath2 = explode('/', substr(ABSPATH, 0, -1));
                $tempPath3 = explode('/', str_replace('\', '/', dirname($_SERVER['PHP_SELF'])));
                
                for ($i = count($tempPath2); $i < count($tempPath1); $i++)
                    array_pop ($tempPath3);
                
                $urladdr = $_SERVER['HTTP_HOST'] . implode('/', $tempPath3);
                
                if ($urladdr{strlen($urladdr) - 1}== '/')
                    define('URLADDR', 'http://' . $urladdr);
                else
                    define('URLADDR', 'http://' . $urladdr . '/');
                
                unset($tempPath1, $tempPath2, $tempPath3, $urladdr);
                

                上面的代码定义了两个常量.ABSPATH 包含应用程序根目录(本地文件系统)的绝对路径,而 URLADDR 包含应用程序的完全限定 URL.它确实适用于 mod_rewrite 情况.

                The above code defines two constants. ABSPATH contains the absolute path to the root of the application (local file system) while URLADDR contains the fully qualified URL of the application. It does work in mod_rewrite situations.

                这篇关于如何找到应用程序的基本网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:PHP:创建可扩展的 CMS 系统 下一篇:IE10 默认跨子域共享 cookie

                相关文章

                最新文章

                    <legend id='hqyWF'><style id='hqyWF'><dir id='hqyWF'><q id='hqyWF'></q></dir></style></legend>

                    <small id='hqyWF'></small><noframes id='hqyWF'>

                  1. <tfoot id='hqyWF'></tfoot>
                  2. <i id='hqyWF'><tr id='hqyWF'><dt id='hqyWF'><q id='hqyWF'><span id='hqyWF'><b id='hqyWF'><form id='hqyWF'><ins id='hqyWF'></ins><ul id='hqyWF'></ul><sub id='hqyWF'></sub></form><legend id='hqyWF'></legend><bdo id='hqyWF'><pre id='hqyWF'><center id='hqyWF'></center></pre></bdo></b><th id='hqyWF'></th></span></q></dt></tr></i><div id='hqyWF'><tfoot id='hqyWF'></tfoot><dl id='hqyWF'><fieldset id='hqyWF'></fieldset></dl></div>
                      <bdo id='hqyWF'></bdo><ul id='hqyWF'></ul>