This is a discussion on Setting PHP Variable to a combination of text and another variables value within the PHP General forums, part of the PHP Programming Forums category; I am trying to set a variable in PHP to a concatinated version of another variable with some text Current ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I am trying to set a variable in PHP to a concatinated version of
another variable with some text Current I know that both of these two line work. $label1=$row_rsPayments['first_name'] $label1="is the first name" But really what I want to be stored in label one is the value of the persons name with "is the first name" after it. I tried joining it like I would in other languages with a & but that didnt work. What is proper syntax to join these two values? |
|
|||
|
tdmailbox@yahoo.com (Rich) wrote in message news:<22e731d7.0406130944.334b63e5@posting.google. com>...
> I am trying to set a variable in PHP to a concatinated version of > another variable with some text > > Current I know that both of these two line work. > $label1=$row_rsPayments['first_name'] > $label1="is the first name" > > But really what I want to be stored in label one is the value of the > persons name with "is the first name" after it. I tried joining it > like I would in other languages with a & but that didnt work. > > > What is proper syntax to join these two values? To concatenate two variables (if they are not strings they will be converted to strings when you concatenate them) use a period (.) $label1 = $row_rsPayments['first_name'] ; $label1 .= " is the first name"; or $label1=$row_rsPayments['first_name'] . " is the first name."; Notice on the second line the .= can be used or in the second example you can just string them together. In general, use this form: $variablex = $variable1 . $variable2 . " something else " . $variable3 .. "<br>\n"; I hope that helps. |