February 5, 201214 yr Hello, I've got what is probably a very simple question but, it has stumped me! Could someone please explain to me what .= means when coding php? Many thanks, Gary
February 5, 201214 yr Concatenate to a string. e.g: $var = "This is a "; $var .= "test demonstration"; echo $var; //prints This is a test demonstration
February 5, 201214 yr The assignment operator is a shorthand for $a .= 'some string'; is the equivalent of $a = $a . 'somestring'; See here for more information
February 6, 201214 yr Author Thanks very much. So it's kind of like adding a bit more onto the end of the string then?
February 6, 201214 yr Yes for a string using the . before the = will do that, but there are others you will find useful $a += 50; Adds 50 to $a Equivalent to $a = $a + 50; $a -= 50; subtracts 50 from $a Equivalent to $a = $a - 50; It's really just a useful shorthand You can do the same with all of the other operators, like *, / and % too
Create an account or sign in to comment