php Laravel5:获取 Laravel 应用的基本 url 或 home url

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29483857/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:26:04  来源:igfitidea点击:

Laravel5: Get base url or home url of the Laravel application

phplaravel-5

提问by Ahmad Sharif

How can I get the base url or home url of the Laravel application ?

如何获取 Laravel 应用程序的基本网址或主页网址?

I have seen similar question. And all of them are based on laravel 4. I have tried the suggesting answer But none of these work in laravel 5. So please consider this things before vote down or treat this as a duplicate.

我见过类似的问题。所有这些都基于laravel 4。我已经尝试了建议的答案但是这些都没有在laravel 5中起作用。所以请在投票之前考虑这些事情或将其视为重复。

回答by Sulthan Allaudeen

You can get the base url of the Laravel application by:

您可以通过以下方式获取 Laravel 应用程序的基本 url:

echo url('/');

or

或者

{{ url('/') }}

Read more about Laravel helpers here

在此处阅读有关 Laravel 助手的更多信息