-3

I'm new to PHP and just analyzing the syntax..

How do I display "1text" here?

$a = 1;
$b = 'text';
$c = $a + $b;

echo $c;
HamZa
  • 14,671
  • 11
  • 54
  • 75
user1804119
  • 142
  • 3
  • 12
  • 1
    In PHP, you use `.` for concatenation. So, it'd be: `$c = $a.$b;` - but please read the [documentation](http://www.php.net/manual/en/language.operators.string.php) and have a look at similar questions before asking a new question. – Amal Murali Feb 02 '14 at 19:15
  • You can also use `$c = "$a$b"` (This is different from concatenation, in that PHP simply replaces `$a` and `$b` in the string with their values) – towr Feb 02 '14 at 19:18

1 Answers1

2

In PHP . is the concatenation operator for strings:

$a = 1;
$b = 'text';
$c = $a . $b;

echo $c;
John Conde
  • 217,595
  • 99
  • 455
  • 496