You are here: Daniel Dumas » Blog, PHP »

PHP Operators: Using String Concatenation Operator

PHP Operators: Using String Concatenation Operator

You can concatenate or add strings together using the PHP string concatenation operator represented by the period sign ( . ). refer to the examples below.

<?php
// intialize variables
$username = "daniel";
$domain = "danieldumas.com";

// the variable string $username and $domain can be combine using the concatenation operator
$email_address = $username . '@'. $domain;

//the variable $email_address now contains the value "daniel@danieldumas.com"

?>

You can also concatenate simultaneously. .

<?php

$name = "dan";

//add and assign values to the string $name..

$name .= "iel";

//the variable $name now contains "daniel"

?>

Discussion

  1. [...] more: PHP Operators: Using String Concatenation Operator Related ArticlesBookmarksTags PHP PHP is a computer scripting language. Originally [...]

  2. You provide good tutorial here – images, examples etc.
    Concatenation though is one of the most basic steps. Wouldn’t you like to concatenate this part with others so we don’t have to go to other page to read this?

  3. semidoppel says:

    I can’t get it because I’m not good at PHP, well I just drop by. :o hhyeahh: Anyway, is it ok if we exchange links? Please add me to your blogroll http://www.semidoppel.com, and please visit my site, you can leave comments and exchange thoughts with me

    semidoppel’s last blog post..PACQUIAO versus HATTON

  4. Todd says:

    Thank you! Very useful. How would you make the above a hyperlink? Actually, I am most interested in, not mail, but using it to create a dynamic URL hyperlink.

  5. yES, agree thank’s for this tutorial, concatenation is basic input to newbie users,.Please wrote more topics about PHP. :D

    Hectic Capiznon Bloggers 2009’s last blog post..A newbie Hectic

  6. tribble says:

    Nice to see something like this tutorial!

  7. You provide good tutorial here – images, examples etc.
    Concatenation though is one of the most basic steps. Wouldn’t you like to concatenate this part with others so we don’t have to go to other page to read this?

Leave a Reply





CommentLuv badge