For the first part:
It seems to work OK on the mail() page where I receive the data via e-mail, BUT, on the page that the user sees and also clicks on SEND, it doesn't work. It only "wraps" to the screen width as without the wordwrap; in other words, it doesn't work at all.
But at the same time there are no errors, notices, warnings, et al showing up on my local server and there is nothing in the Apache Error Log.
So I guess my question is, SHOULD it display properly on the mail() page? Which is PHP,BTW. Or is it something like a textarea where maxlength doesn't work?
No, it shouldn't; at least, not if you're rendering it as unformatted text in an HTML page. (Try looking at the source code of the page instead of your browser's interpretation of it.)
I guess what I'm actually asking is, WHERE/HOW, other than experimentation, can I learn more about execution sequences in PHP?
Start at the beginning, then go through line by line, jumping to other lines if the PHP statements dictate you do so.
http://www.php.net/manual/en/control-structures.intro.php
For the second part, I don't understand either part of your question. A: the "assignment of VARs" isn't being echoed anywhere. As for B: there are echo statements before your variable assignments because you put them there. And the only echo statements that use the values of variables you assigned to appear after you are below the assignments.
Your code with each line appearing in the order in which it is executed:
// VAR setup:
Comment; no functional effect.
echo "VAR SETUP; Normally these would be from an online form entries : <br />";
Output the string [font=monospace]VAR SETUP; Normally these would be from an online form entries : <br />[/font].
$comments = "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In posuere felis nec tortor. Pellentesque faucibus. Ut accumsan ultricies elit. Maecenas at justo id velit placerat molestie. <br />";
Assign the string [font=monospace]Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In posuere felis nec tortor. Pellentesque faucibus. Ut accumsan ultricies elit. Maecenas at justo id velit placerat molestie. <br />[/font] as the value for the variable [font=monospace]$comments[/font].
$zip = "13654";
Assign the string [font=monospace]13564[/font] as the value for the variable [font=monospace]$zip[/font].
$email = "nobody@spamcop.net ";
Assign the string [font=monospace]nobody@spamcop.net [/font] as the value for the variable [font=monospace]$email[/font].
// EXECUTION:
Comment; no functional effect.
$email . "<br />";
No functional effect - the value of the expression is not output nor assigned to anything.
echo "zip IS " . $zip . "<br />";
Output the string made by concatenating the string [font=monospace]zip IS [/font] with the current value of the variable [font=monospace]$zip[/font] and the string [font=monospace]<br />[/font].
$comments = wordwrap($comments,40);
Apply the [font=monospace][man]wordwrap[/man][/font] function to the current value of the variable [font=monospace]$comments[/font] and assign the resulting value to the variable [font=monospace]$comments[/font].
echo " tHE COMMENTS ARE <br />" . $comments . "<br />";
Output the string made by concatenating the string [font=monospace] tHE COMMENTS ARE <br />[/font] with the current value of the variable [font=monospace]$comments[/font] and the string [font=monospace]<br />[/font].
echo "done<br /><br />";
Output the string [font=monospace]done<br /><br />[/font].
echo "All together now: <br />" . $email . "<br />" . $zip ."<br />" . $comments;
Output the string made by concatenating the string [font=monospace]All together now: <br />[/font] with the current value of the variable [font=monospace]$email[/font], the string [font=monospace]<br />[/font], the current value of the variable [font=monospace]$zip[/font], the string [font=monospace]<br />[/font], and the current value of the variable [font=monospace]$comments[/font].
So the net result is that the output consists of:
VAR SETUP; Normally these would be from an online form entries : <br />
zip IS 13654<br /> tHE COMMENTS ARE <br />Pellentesque habitant morbi tristique
senectus et netus et malesuada fames ac
turpis egestas. In posuere felis nec
tortor. Pellentesque faucibus. Ut
accumsan ultricies elit. Maecenas at
justo id velit placerat molestie. <br /><br />done<br /><br />All together now: <br />nobody@spamcop.net <br />13654<br />Pellentesque habitant morbi tristique
senectus et netus et malesuada fames ac
turpis egestas. In posuere felis nec
tortor. Pellentesque faucibus. Ut
accumsan ultricies elit. Maecenas at
justo id velit placerat molestie. <br />
If that's not what you expected, what exactly did you expect, and why?