Setting PHP Variable to a combination of text and another variables value

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-13-2004
Rich
 
Posts: n/a
Default Setting PHP Variable to a combination of text and another variables value

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?
Reply With Quote
  #2 (permalink)  
Old 06-14-2004
Jondolar
 
Posts: n/a
Default Re: Setting PHP Variable to a combination of text and another variables value

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.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:19 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0