Re: Dynamically generating PHP functions?

From: Date: Fri, 15 Sep 2000 13:07:07 +0000
Subject: Re: Dynamically generating PHP functions?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-16940@lists.php.net to get a copy of this message
Although I haven't tried this myself, theoretically all you need to do is to build up the code for the function in a string, and then call eval() on it. You won't be able to pass parameters to it, but you can interpolate variables into the string. Keep in mind that (according to the docs) you will need to use PHP4 if you want to be able to get a return value from eval(). -- Dave On Fri, 15 Sep 2000 15:01:04 +1030, Joseph H Blythe said: > Hey, > > I have written a script that dynamically generates a form from a given > database and table that would be suitable, as a generic data input > device for any mysql table. > > My problem is that when I have tried to write the script for the forms > action i.e.: > > .... > mysql("database","INSERT INTO table Values ( > '$field1', > '$field2', > '$field3', > '$field4' > )"); > > > I cannot figure out how to generate the above function dynamically so > that that it has the correct number of fields for the given database > table, does anyone know how one would go about writing php functions > dynamically then executing them? > > I suppose it is much the same as the way php dynamically generates html, > but I need it to do it on itself, if this makes any sense. > > Any help would be much appreciated. > > Joseph > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > -- Dave Seidel CulturePort, Inc. dave@superluminal.com

« previous php.general (#16940) next »