...

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



milesdriven
07-27-2012, 10: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:


'_string'


...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:


.Jul.11.2012.


This:


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


Sends this to the browser:


".$M3.$hi.$Y."8AM


This brings the variables together like I want:


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


Sends this to the browser:


May12012


But adding a string to it like this:


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


Sends this to the browser:


"$M3$hi$Y"8AM


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


".$M3."


and this:


"$M3"


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

DrDOS
07-27-2012, 10:54 PM
this
$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.

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

I've figured out this:


$M3.$hi.$Y.'8AM_list'


...will give me this:


Jul120128AM_list


This:


'"'.$M3.$hi.$Y.'8AM_list"'


Will send this to the browser:


"Jul120128AM_list"

DrDOS
07-28-2012, 01:44 AM
'"'.$M3.$hi.$Y.'8AM_list"'

milesdriven
07-28-2012, 01: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.

Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum