• BOOKMARK

  • ADD TO FAVORITES

  • REFERENCES


  • MARC

    Mailing list ARChives
    - Search by -
     Subjects
     Authors
     Bodies





    FOLDOC

    Computing Dictionary




  • Text Link Ads






String Concatenation

PHP Tutorials.

String Concatenation

New postby Ranman on Thu Mar 27, 2008 10:37 pm

Code: [Select all] [Expand/Collapse] [Download] (Untitled)
General form:

   Single-quoted strings are taken as literals

   Double-quoted Strings
    -they can include backslash escaped characters like \n, \r, etc.
    -they can also include variables, and they will replaced

   "Concatenation" means joining two Strings into one
   String concatenation - the dot operator


Q. What is the diffrence between " and '?
A. By example:

   This will print "This is a text string."

<?
$string = "is a";
$text = "This $string text string.";
echo $text;
?>


   This will print "This $string text string."

<?
$string = "is a";
$text = 'This $string text string.';
echo $text;
?>


Example 1:

   The following prints "Some text then PHP"

<?
$a = "PHP";
echo $b = "Some text then $a";
?>


Example 2:

   The following prints "There are 31 days in this month"

<?
$str = "There";
$str = $str." are ";
$str .= date("t");
$str .= " days in this month.";
echo $str;
?>


Example 3:

   The following prints "The value or the variable $var is 5."

<?
$var = 5;
$str = 'The value or the variable $var is '.$var.'.';
echo $str;
?>


User avatar
Ranman
Site Admin
 
Posts: 25
Joined: Thu Mar 27, 2008 12:27 am

Return to PHP Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest

  • MORE RESOURCE


  • Linux

    The Distributions





    Linux

    The Software





    Linux

    The News



  • MARKETING






  • Toll Free
cron