我尝试了所有这些,但无法预测插值,请阅读官方 documentation 中的所有点但尚未找到优雅的解决方案-
{{ url('/posts/' . $post->id . '/comments' }}
{{ url('/posts/$post->id/comments') }}
最后这个成功了,但我期待比这更优雅的东西
@php
$url = url('/posts/' . $post->id. '/comments');
@endphp
{{ $url }}
最佳答案
您可以尝试这些:-
{{ url('/posts/' . $post->id . '/comments') }} // ) missing
或者:-
{{ url("/posts/$post->id/comments") }} // double quotes
关于php - Laravel 中的字符串插值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45468181/