| Home > Computer & I'net > Strings - Connecting... |
|
|
|||||||||||||||
|
|
|||||||||||||||
|
||||||||||||||||
Strings - Connecting | |
$NewString = $string1 . $string2; The value of $NewString is the combination of $string1 and $string2. This is not addition like in math. This is taking the value of $string2 and plunking it onto the end of $string1. <?php $string1 = "This is an example"; $string2 = "of connecting strings."; $NewString = $string1 . $string2; echo "$NewString"; ?> This is an exampleof connecting strings. Hmmm... that doesn't quite look right. There should be a space between the words example and of. Let's add in a space on the connecting code line : $NewString = $string1 . " " . $string2; This is an example of connecting strings.
So you can add strings, direct quoted data, and so forth together. Some "real world" example of using this may be to combine a $FirstName and $LastName into one string. There could be many other uses as well. ----------------- Article by David Stanley. Visit his site http://www.htmlite.com. Reprinted with permission. | |
| Articles |
•Auto & Trucks•Business•Computer & I'net·General·Apache·CSS·Database·Hardware·HTML·Javascript&DHTML·Linux·MySQL·Operating System·Perl / CGIPHP·Programming·Publishing·Search Engines·Software Problems·SSI·Tips & Tricks·Utilities·Web Design•Family•Food & Drink•Gardening•Health•Other•Pets•Psychology•Spiritual•Travel•Women |
| Calculators |
|