Date: 11/20/99
- Next message: Kristian Koehntopp: "Re: [PHPLIB] Using Setup.inc"
- Previous message: Michael S. Steuer: "RE: [PHPLIB] fopen("http...."
- Next in thread: Ulf Wendel: "[PHPLIB] Changes to oohform, was: Kristian: A couple questions please"
- Reply: Ulf Wendel: "[PHPLIB] Changes to oohform, was: Kristian: A couple questions please"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello,
Would you please post to the list a short description of
how to use the new functions "generate_php()" and/or
"php_validate()".
And maybe you could answer this, allthough it is probably
a genearal php question. I came to the conclusion that a
good method of adding oohform elements to pages would
be to separate the add_elements() methods from the pages
that display them by placeing all the add_element()
methods in one "include file", wrapping them in a fuction,
and then calling only the add_elemets that I need on a
page-by-page basis.... with a function like so:
// the page that calls the add_elements()
require("oohforms.inc");
$f = new form;
include("all_elements.php3");
$el_array = "this","that","the_other");
myadd_elements($el_array);
//...and in all_elements.php3 I have:
function myadd_elements($el_array){
global $f;
while (list($thekey, $theval) = each($el_array)) {
switch ($theval){
case 'this':
$f->add_element(...)
case 'that':
$f->add_element(...)
case 'the_other':
$f->add_element(...)
}
}
But I ran into a problem. Since different form object
instances will be using "all_elements.php3" I would like
declare the form object instance on the calling page ( which I
do above with: $f = new form; ) But if I create an new instance
of 'form' with a different name ( such as $myform = new form; )
the add_elements() inside "all_elements.php3 will fail because
they have the object name $f and not $myform.
So to fix this I tryed passing the name of the "form object
instance" as a function argument like:
myadd_elements("myform",$el_array);
...and then tryed $f a "variable variable":
${$f}->add_element(...)
so $f would equal $myform:
$myform->add_element(...)
This is what the code looks like after my cahanges that
did not work:
// the page that calls the add_elements()
require("oohforms.inc");
$myform = new form;
include("all_elements.php3");
$el_array = "this","that","the_other");
myadd_elements("myform",$el_array);
//...and in all_elements.php3 I have:
function myadd_elements($f,$el_array){
global $f
while (list($thekey, $theval) = each($el_array)) {
switch ($theval){
case 'this':
${$f}->add_element(...)
case 'that':
${$f}->add_element(...)
case 'the_other':
${$f}->add_element(...)
}
}
Is there a way to do what I am trying to do? which is,
pass the name of the object to my function and then perform
methods on that object?
...so this:
${$f}->add_element(...)
..in reality is this:
$myform->add_element(...)
Sorry for the long post.... didn't realize it would take
so mutch to explain :-)
Thanks in advance,
Bob
P.S. One last question if I may. When I named the file
"all_elements.php3" with a .inc extension and then included
it, I would get an undefined function when calling
myadd_elements(); . It seams that it has to have a php3
extenstion in order for me to call the functions inside
it. If this is so, how then does phplib work with all the
.inc files?
__________________________________________________
FREE Email for ALL! Sign up at http://www.mail.com
-
PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
the body, not the subject, of your message.
- Next message: Kristian Koehntopp: "Re: [PHPLIB] Using Setup.inc"
- Previous message: Michael S. Steuer: "RE: [PHPLIB] fopen("http...."
- Next in thread: Ulf Wendel: "[PHPLIB] Changes to oohform, was: Kristian: A couple questions please"
- Reply: Ulf Wendel: "[PHPLIB] Changes to oohform, was: Kristian: A couple questions please"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

