|
Posted by Koncept on 10/11/88 11:57
In article <1157211267.359847.323430@p79g2000cwp.googlegroups.com>,
kenoli <kenoli@igc.org> wrote:
> I'm quite impressed and learned a bunch of things from this including
> some things about html I didn't know.
:)
>
> I want to make sure I undeerstand something I didn't know before:
>
> In the tags where you include something like: name = "proc[firstname]"
>
>
> I presume that what is going on here is that an array called "proc[]"
> is being created as an element in the global $_POST variable which
> contains the content of the input fileds associated with their name
> attributes as keys. For each input, a new array elemtn with key is
> concatenated to the proc[] array. Do I understand this correctly?
>
> If so, this is quite elegant.
You got it.
> Is there some specific reason you did it this way. I could imagine
> keying the switch statement to a text key assigned by each name
> attribute, as well.
It's tidier to build containers for related data. If I had an array set
containing customer details such as name, email, etc etc, I could
simply session that one post variable (since it is an array). Another
little cheat I sometimes use is casting the array to an object so that
I can avoid typing so many quotes and brackets:
<?php
$a["name"] = "joe";
$a["age"] = "55"];
....
$a = (object) $a;
echo "The person named ",$a->name, " is ",$a->age," years old.";
?>
* Yes... I am lazy enough that saving two keystrokes matters ;)
> I hadn't been aware of how many tags can be associated with html form
> elements. Many of those included here are obviously not utilized in
> the included php script, but I can see how they could be used. Is
> there some reason you included them?
My editor is snippet based and automatically creates some predefined
attributes such as ID with certain tags. Since I often use javascript
and CSS to help with the look/feel/function of pages, ID attributes
have become something of a necessity over time since they can uniquely
single out nodes.
> What is your reason for including the CDATA striing in the style
> section. I know generally what this does but wonder about its
> application here. Is it just to create bulletproof code or is there a
> specific function? I presume any interpreter that cares about it will
> read through the comment tags.
More recent XHTML standards process code between script tags as PCDATA
( parsed character data ) - which is then evaluated by validators.
Since this is not valid XHTML markup, you would have an invalid page.
Using CDATA sections ( character data ), the markup contained in these
regions is ignored and guarentees that the page is processed properly
by browsers which cannot properly support the XHTML DTD.
>
> Any reason for using if indif format instead of {} in the if statement
> aside from personal style? Ditto for "foreach."
Just a style I use depending on what I am doing. Nothing more than
personal preference.
--
Koncept <<
"The snake that cannot shed its skin perishes. So do the spirits who are
prevented from changing their opinions; they cease to be a spirit." -Nietzsche
Navigation:
[Reply to this message]
|