View Full Version : Need help understanding the dot "."

07-27-2012, 09:32 PM
I'm trying to learn how the period "." works. Sometimes its concatenation, sometimes its echoed to the browser.

I'm trying to add a string, such as:


...to a set of variables, such as:

$M3 = 'May';
$hi = '1';
$Y = '2012';

To get this:

"May12012_string" ( or with single quotes )

I asked this question before, and got an answer, but I can't get it to work anymore. For example, this:

$time = ".$M3.$hi.$Y.";
echo $time;

Shows up as this in the browser:



$time = '".$M3.$hi.$Y."8AM';
echo $time;

Sends this to the browser:


This brings the variables together like I want:

$time = "$M3$hi$Y";
echo $time;

Sends this to the browser:


But adding a string to it like this:

$time = '"$M3$hi$Y"8AM'
echo $time;

Sends this to the browser:


What is the difference between this (when is this necessary?):


and this:


I hope I asked the question clearly.
Thanks for your help.

07-27-2012, 09:54 PM
$time = ".$M3.$hi.$Y."; should give you .May.2.2012.
but this
$time = $M3.$hi.$Y; should give you May22012
and this
$time = $M3.".".$hi.".".$Y; should give this May.2.2012

Confusing enough? It is for me! It gets better with practice.

07-27-2012, 09:59 PM
Practice is definitely what I'm doing.

I've figured out this:


...will give me this:




Will send this to the browser:


07-28-2012, 12:44 AM

07-28-2012, 12:52 AM
Hi DrDos,

Thanks. I posted the very same thing (I just figured it out with the help of your earlier example) about the same time you answered. I wanted to be able to do it with quotes and without.