English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

$address = '$street' & '$postcode' & '$city' & '$state'; //how to join this? this is not correct. i want to join street, postcode, city and state in 1 variable (address) so i can add a complete address in 1 field.

2007-03-18 00:14:18 · 2 answers · asked by James Bond 5 in Computers & Internet Programming & Design

2 answers

$address = '$street' . '$postcode' . '$city' . '$state';

"." is the concatanation operator - not "&"

2007-03-18 00:22:07 · answer #1 · answered by r_ranjith 4 · 1 0

As said, you need . but also when using single quotes (') variables won't be replaced with their values. So either you need to do:

$address = $street . $postcode . $city . $state;

Or use double quotes (no use in this case, but would if you'd want characters in between):

$address = "{$street}{$postcode}{$city}{$state}";

So with characters:

$address = "I live in street $street, my postal code it $postcode in the city $city. My state: $state.";

2007-03-18 02:27:42 · answer #2 · answered by Vincent Z 2 · 1 0

fedest.com, questions and answers