Jump to content

[SOLVED] .= ?? what is it exacly?


Foser

Recommended Posts

As we have already seen in the Echo Lesson, the period "." is used to add two strings together, or more technically, the period is the concatenation operator for strings.

 

PHP Code:

$a_string = "Hello";

$another_string = " Billy";

$new_string = $a_string . $another_string;

echo $new_string . "!";

 

Display:

Hello Billy!

 

link

http://www.tizag.com/phpT/operators.php

Link to comment
Share on other sites

The .= operator is handy if you have a loop running and want to repeatedly add something onto the end of a string.

 

<?php
  $txt='';
  for ($i=0;$i<5;$i++) {
    $txt.='*';
  }
  echo $txt;
?>

 

The above is exactly the same as this:

 

<?php
  $txt='';
  for ($i=0;$i<5;$i++) {
    $txt=$txt.'*';
  }
  echo $txt;
?>

 

All the above does is make a string containing "*****" (five stars)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.