gpt4 book ai didi

php - Symfony HttpFoundation 请求 getBaseUrl() 与 getBasePath()

转载 作者:搜寻专家 更新时间:2023-10-31 22:02:12 26 4
gpt4 key购买 nike

getBaseUrl 之间有什么区别?和 getBasePath Symfony\Component\HttpFoundation\Request 的?我想知道什么时候使用一个而不是另一个。

最佳答案

getBaseUrl 还包括脚本文件名。

phpDoc 注释给你进一步的解释:

获取基本路径:

/**
* Returns the root path from which this request is executed.
*
* Suppose that an index.php file instantiates this request object:
*
* * http://localhost/index.php returns an empty string
* * http://localhost/index.php/page returns an empty string
* * http://localhost/web/index.php returns '/web'
* * http://localhost/we%20b/index.php returns '/we%20b'
...

getBaseUrl:

/**
* Returns the root URL from which this request is executed.
*
* The base URL never ends with a /.
*
* This is similar to getBasePath(), except that it also includes the
* script filename (e.g. index.php) if one exists.
...

关于php - Symfony HttpFoundation 请求 getBaseUrl() 与 getBasePath(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26863962/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com