Laravel 使用HTTP客户端API发送动态变量

Laravel 使用HTTP客户端API发送动态变量,laravel,api,eloquent,Laravel,Api,Eloquent,如何在此函数中发送{word\u id}中的变量$word 我试过了 public function index($word) { $response = Http::withHeaders([ 'app_id' => 'xxxxxxx', 'app_key' => 'xxxxxxxxxxxxxxxx' ])->get('https://od-api.oxforddicti

如何在此函数中发送
{word\u id}
中的变量$word
我试过了

public function index($word)
    {
        
        $response = Http::withHeaders([
            'app_id' => 'xxxxxxx',
            'app_key' => 'xxxxxxxxxxxxxxxx'
        ])->get('https://od-api.oxforddictionaries.com/api/v2/lemmas/en/{word_id}')->json();
       return $response 
    }

你可以像这样把它浓缩成
get('https://od-api.oxforddictionaries.com/api/v2/lemmas/en/“.$word)
或者您可以像下面这样使用双引号
get(”https://od-api.oxforddictionaries.com/api/v2/lemmas/en/$word“

我想你能理解,为什么不呢?@Miqayel你能解释一下吗?像这样
->明白吗('https://od-api.oxforddictionaries.com/api/v2/lemmas/en/“.$word)
而不是
{word\u id}
传递
${word}
(https://od-api.oxforddictionaries.com/api/v2/lemmas/en/{word_id}',['word_id'=>$word]);
GOt error