In bash, you can include a variable as part of a filename. For
example:
date=$(date)
cat log.txt > $date"_log.txt"
Which, when setting the right options in date, creates a file named
20040705_log.tx t
I am now trying to call a class based on a previously defined variable
set by an array:
1 $field[1] = "first_name ";
7 $field[2] = "mi";
8 $field[3] = "last_name" ;
12 foreach ($field as $field_name) {
13 $var_validate_f ield = &New "cls_validate_" $field_name;
14 $var_strip_fiel d = &New "cls_strip_"$fi eld_name;
15 $record[$field_name] = $_POST[$field_name];
16 $record_check[$field_name] =
$var_validate_f ield->fn_validate($r ecord[$field_name]);
17 $record[$field_name] =
$var_strip_fiel d->fn_strip($reco rd[$field_name]);
18 print "<p>$field_ name is $record[$field_name] and its check is
$record_check[$field_name]";
19 }
As you can see, I am trying to make $field_name part of the name of
the class, but it is not working. Everything else works fine; I've
tested the classes individually; but the array method will not work
without this. Suggestions are welcome. Thank you.
example:
date=$(date)
cat log.txt > $date"_log.txt"
Which, when setting the right options in date, creates a file named
20040705_log.tx t
I am now trying to call a class based on a previously defined variable
set by an array:
1 $field[1] = "first_name ";
7 $field[2] = "mi";
8 $field[3] = "last_name" ;
12 foreach ($field as $field_name) {
13 $var_validate_f ield = &New "cls_validate_" $field_name;
14 $var_strip_fiel d = &New "cls_strip_"$fi eld_name;
15 $record[$field_name] = $_POST[$field_name];
16 $record_check[$field_name] =
$var_validate_f ield->fn_validate($r ecord[$field_name]);
17 $record[$field_name] =
$var_strip_fiel d->fn_strip($reco rd[$field_name]);
18 print "<p>$field_ name is $record[$field_name] and its check is
$record_check[$field_name]";
19 }
As you can see, I am trying to make $field_name part of the name of
the class, but it is not working. Everything else works fine; I've
tested the classes individually; but the array method will not work
without this. Suggestions are welcome. Thank you.
Comment