php - GuzzleHttp and Laravel - Syntax error - T_String -


i trying use guzzlehttp laravel access api based on user's input.

my set-up far:

$client = new \guzzlehttp\client(); $response = $client         ->get('https://api.postcodes.io/postcodes/'input::get('postcode')); dd($response->getbody()); 

but error being returned is:

fatalerrorexception in cliniccontroller.php line 129: syntax error, unexpected 'input' (t_string)

line 129 https://api.postcodes.io/postcodes/'input::get('postcode')

any why occurring hugely appreciated.

that's simple php error. here's line php complaining about

->get('https://api.postcodes.io/postcodes/'input::get('postcode')); 

you have string

'https://api.postcodes.io/postcodes/' 

immediately followed input::get('postcode'). if you're trying combine these two, you'll want use . operator concatenate strings

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

also, consider -- in production application, you'd want either sanitize or validate input::get('postcode') contains post code before using in url request that. assume try use system maliciously, , never trust user input contain think contains.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -