Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a . (dot) do in PHP?

Tags:

php

What does the following command do in PHP?

. $string   // ($string is something which I declared in the program) 
like image 458
John Tor Avatar asked Jun 26 '11 15:06

John Tor


People also ask

What is Dot equal PHP?

the " . = " operator is a string operator, it first converts the values to strings; and since " . " means concatenate / append, the result is the string " 120 ".

What does 3 dots mean in PHP?

This is the so called "splat" operator. Basically that thing translates to "any number of arguments"; introduced with PHP 5.6.

What are PHP string operators?

There are two string operators. The first is the concatenation operator ('. '), which returns the concatenation of its right and left arguments. The second is the concatenating assignment operator (' .

Is used for concatenation in PHP?

The PHP concatenation operator (.) is used to combine two string values to create one string. Concatenation assignment. Example: <?


1 Answers

On its own, that does nothing at all (it's not valid syntax). However, if you have something like this:

<?php  $string1 = "Hello "; $string2 = "world!"; $string = $string1 . $string2;  echo $string;  ?> 

You will see Hello world!. The . is the string concatenation operator.

like image 83
Oliver Charlesworth Avatar answered Sep 27 '22 18:09

Oliver Charlesworth