javascript - Append user data to url before sending request in PHP -


what easiest way append form data json url prior sending request? know next nothing php im trying either way

the php have far, need replace zip before.json content im getting $_get['zip']

<?php   $zip = $_get['zip'];   $zip_data = file_get_contents($zip);   $weather_data = file_get_contents("http://api.wunderground.com/api/myapi/conditions/q/zip.json");   echo $weather_data; ?> 

in php if put variable name inside string quoted double quotes, puts value string:

$weather_data = file_get_contents(".../q/$zip.json"); 

you can put curly brackets around make cleaner read:

$weather_data = file_get_contents(".../q/{$zip}.json"); 

or can close string, use dot operator concatenate, , reopen string:

$weather_data = file_get_contents(".../q/" . $zip . ".json"); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -