frogrocker said:
1. What's with all the dots?
2. How does $mailcontents seem to have more than one value..
1.
The documentation is always useful for this sort of question. Please use it to answer your questions as frequently as possible. But I'll indulge you anyhow. In php, . is the concatenation operator, and .= is the concatenating assignment (append) operator. They are the operators for joining two or more strings. To demonstrate:
Code:
<?
$a = 'united';
$b = 'states';
echo $a . $b; // This will print "unitedstates"
$c = $a . $b;
echo $c; // This will also print "unitedstates"
$a .= $b // This appends the contents of $b to the end of $a
// The above is essentially a shortcut for $a = $a . $b;
echo $a; // This will also print "unitedstates"
?>
This is very basic PHP and you will need to know it to create all but the simplest scripts in PHP. I recommend that you read a good basic PHP tutorial. Webmonkey has
a tutorial that looks reasonably good. Once you've gone through all of these exercises, you may want to read the documentation for the
String type. This will answer your second question, as well, but I'll take a stab at it anyhow.
2. $mailcontents does not contain more than one value. It contains a single string. When denoting a string using double-quotes (e.g. $mystring = "something"
, you can also include special characters. The characters "\n" represent the "newline" character, which is what split the $mailcontents into several lines when it sent the e-mail. To demonstrate:
Code:
<?
$a = "this is\nthree\nseparate lines";
echo $a;
/* The output will look like this:
----------
this is
three
separate lines
----------
Using the concatenation operator as I demonstrated
above, you can also rewrite the above in a slightly more
readable manner, and it is a good idea to do so:
*/
$b = "this is\n" .
"three\n" .
"separate lines";
/* Make note of the dots at the end of each line (except the
last). The variables $a and $b now have identical contents
(you can test this using "if($a === $b) ...").
*/
?>
So you see, it has converted each instance of "\n" into a line break. It's important to note, however, that when you output to an HTML file and view that file in your browser, newlines will be ignored and the above would look like "this is three separate lines". To produce a line break in HTML, you must use the HTML tag "<br />" (the trailing slash is for XHTML compliance). So to make the above appear as three lines in your browser, you should instead make your code like the following:
Code:
<?
$a = "this is<br />\n" .
"three<br />\n" .
"separate lines";
?>
For reference, another way to insert an HTML line break before every newline is using the PHP function
nl2br().
I hope that was helpful, and I hope you take the time to read all of the links I have posted.