Reply to Re: Dynamic function creation?

Your name:

Reply:


Posted by jussist@gmail.com on 01/04/07 06:51

> is it possible to dynamically create function? so I only need to
> declare one setter, and one getter?

I have used two solutions for that. I have somewhere a script, to which
you input your fieldnames in a form, and the script generates the class
skeleteon, with fields, getters, setters and indentation.

Field $name becomes function getName() and setName($param) etc..

I've also done a helper, which did all that from database, but I think
that was in java and few years back. I can try and remember to post
that script here, if I remember when I go to the office. That will be
earliest saturday, latest next wednesday.

Writing that kind of script is actually not that huge task.

$src = "Class " . $_POST["class_name"]. " { \n\n";
$src .= "\t\$" . $fieldname . ";\n\n";
$src .= "\tget" . ucfirst($fieldname) . "() {\n";
$src .= "\t\treturn \$this->" . $fieldname . ";\n";

And so on. Just output that and copy/paste - or generate the file with
your script.

Jussi

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация