-4

I want to know how can I concatenate both these echo's together:

<?php echo $_SESSION['id'] ?><?php echo $sessionConcat ?>

I wanted it to concatenate the echos so that the concatenate echos can be then set to a variable, e.g.

$assessment = //concatenated echo
  • 1
    Google "php concatenate". first result. Also http://stackoverflow.com/questions/3354595/php-operator-confusion-a-beginners-question/3354614 and http://stackoverflow.com/questions/6484968/what-does-a-dot-do-in-php – Mike B Nov 01 '12 at 21:46

3 Answers3

4

Is this what you're trying to accomplish?

$assignment = $_SESSION['id'] . $sessionConcat;
Daniel Doezema
  • 1,592
  • 10
  • 13
4

The . operator is used to concatenate strings in PHP.

$assessment = $_SESSION['id'] . $sessionConcat;
Collin Price
  • 5,620
  • 3
  • 33
  • 35
0

If you can change that code, just use use the . (dot) operator.

If You want to catch the output, use ob_start() (before) and ob_get_contents() (after), to get what normally would be echoed.

PiotrN
  • 310
  • 1
  • 3