Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJavid Abbasov
9,243 PointsDots between code
Hi. Why do we need to put dots between code?
echo "-" . $movie["title"] . "-";
2 Answers
Jacob Mishkin
23,118 PointsIts because they concatenating operators. when dealing with string elements.
mohammed abdi abdulahi warsame
4,926 Pointsbut i thing we can just use -comma , - "Hello, world, !" WHAY do we need to use dots
john larson
16,594 Pointsmohammed, I believe we have to use dot . when putting a variable in a string. as in;
<?php
$earth = "world";
echo "Hello ".$earth. " and good morning";
?>
Javid Abbasov
9,243 PointsJavid Abbasov
9,243 Pointsi didnt understand(
Jacob Mishkin
23,118 PointsJacob Mishkin
23,118 Pointsyou didn't understand what I said or using the "." operator?
Javid Abbasov
9,243 PointsJavid Abbasov
9,243 PointsI didnt answer what you say
Jacob Mishkin
23,118 PointsJacob Mishkin
23,118 PointsThat's cool, lets break it down. I don't know if English is your first language, but these are words in English that if you are programming you should know.
first, concatenation means to join things, or group things together. just like in JavaScript the "+" sign, the "." is for PHP. Remember you can can't use the "+" in PHP like in JavaScript, but they mean the same thing.
here is an example first in JavaScript then in PHP
JavaScript:
PHP:
The word operators means what sign of operation you doing. Operators are the signs for addition, subtraction, and other operations like concatenation.
I hope this helps, If you need to dive deeper let me know.
Javid Abbasov
9,243 PointsJavid Abbasov
9,243 PointsThank you very much!! But can we use + instead of . ?
Jacob Mishkin
23,118 PointsJacob Mishkin
23,118 PointsNO, you can ONLY use "." in PHP.