我需要从函数调用的返回和变量中连接/连接字符串,而不使用传统的连接。
。
在这种情况下,它应该显示一个 url 字符串。
下面是我的实际代码。
代码:
$test = "{ config('app.url') }/{ $username }";
die(print_r($test));
当前结果:
{ config('app.url') }/testuser
预期结果:
http://localhost:8000/testuser
最佳答案
您可以在带引号的字符串中阅读有关复杂( curl )语法的更多信息,但是您可以使用该代码实现您想要的效果:
$test = "{${config('app.url')}}/{$username}";
die(print_r($test));
但我个人更喜欢:
$appUrl = config('app.url');
$test = "{$appUrl}/{$username}";
die(print_r($test));
这对你有用吗?
关于php - 如何显示连接内函数调用的字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54211067/