Saturday 27 July 2019

What does a . (dot) do in PHP?



What does the following command do in PHP?




. $string   // ($string is something which i declared in the program)

Answer



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




$string1 = "Hello ";
$string2 = "world!";
$string = $string1 . $string2;


echo $string;

?>


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


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...