Php GuzzleHttp和Laravel-语法错误-T_字符串

Php GuzzleHttp和Laravel-语法错误-T_字符串,php,laravel,laravel-5,guzzle,Php,Laravel,Laravel 5,Guzzle,我目前正在尝试将http与Laravel一起使用,以根据用户的输入访问API 我目前的设置: $client = new \GuzzleHttp\Client(); $response = $client ->get('https://api.postcodes.io/postcodes/'Input::get('postcode')); dd($response->getBody()); 但返回的错误是: ClinicController.php第129行中的Fa

我目前正在尝试将http与Laravel一起使用,以根据用户的输入访问API

我目前的设置:

$client = new \GuzzleHttp\Client();
$response = $client
        ->get('https://api.postcodes.io/postcodes/'Input::get('postcode'));
dd($response->getBody());
但返回的错误是:

ClinicController.php第129行中的FatalErrorException:语法错误, 意外的“输入”(T_字符串)

第129行是
https://api.postcodes.io/postcodes/'输入::获取('邮政编码')

如果您能提供任何帮助,我们将不胜感激。

请尝试以下方法:

$client = new \GuzzleHttp\Client();
 $response = $client
        ->get('https://api.postcodes.io/postcodes/'.Input::get('postcode'));
 dd($response->getBody());
请尝试以下操作:

$client = new \GuzzleHttp\Client();
 $response = $client
        ->get('https://api.postcodes.io/postcodes/'.Input::get('postcode'));
 dd($response->getBody());

这是一个简单的PHP错误。这是PHP抱怨的一句话

->get('https://api.postcodes.io/postcodes/'Input::get('postcode'));
你有一根绳子

'https://api.postcodes.io/postcodes/'
紧接着是
Input::get('postcode')
。如果要将这两个字符串组合起来,则需要使用
操作符来连接字符串

 'https://api.postcodes.io/postcodes/' . Input::get('postcode')

还有一些要考虑的事情——在一个生产应用程序中,你想清理或验证<代码>输入::GET(“邮政编码”)实际上包含了一个邮政编码,然后在这样的URL请求中使用它。始终假设有人会恶意使用您的系统,永远不要相信用户输入会包含您认为它包含的内容

这是一个简单的PHP错误。这是PHP抱怨的一句话

->get('https://api.postcodes.io/postcodes/'Input::get('postcode'));
你有一根绳子

'https://api.postcodes.io/postcodes/'
紧接着是
Input::get('postcode')
。如果要将这两个字符串组合起来,则需要使用
操作符来连接字符串

 'https://api.postcodes.io/postcodes/' . Input::get('postcode')

还有一些要考虑的事情——在一个生产应用程序中,你想清理或验证<代码>输入::GET(“邮政编码”)实际上包含了一个邮政编码,然后在这样的URL请求中使用它。始终假设有人会恶意使用您的系统,永远不要相信用户输入会包含您认为它包含的内容

谢谢你,艾伦,我想
输入::
是否对所有输入进行消毒?邮政编码在使用前通过一个
正则表达式
检查器。谢谢你,艾伦,我想
输入::
是否对所有输入进行消毒?邮政编码在使用前通过一个
正则表达式
检查器。谢谢你,艾伦,我想
输入::
是否对所有输入进行消毒?邮政编码在使用前通过
正则表达式
检查器传递。