Re: Prefix function name problem

From: Date: Tue, 30 Mar 2004 01:16:27 +0000
Subject: Re: Prefix function name problem
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-26867@lists.php.net to get a copy of this message
I think HTML_Table does something like this. - interesting idea though - I thought __call() + overload may be a very interesting way to implement this.. it might be interesting to play around adding it to HTML_Template_Flexy_Element.. Regards alan Guillaume Lecanu wrote:
Hi, I have make a PHP lib to create functions equivalent of HTML tags for make "valid" page. This is the equivalent of mod_cgi in perl. An example : table(array (style => 'mytable', width => '80%').
        tr(
                td(array (width=>'50%'), "Hello").
                td(array (width=>'50%'), "World")
        )
) This coding style is very usefull, but i can't propose this lib to PEAR because all functions must be prefixed by the name of the package. 1st Solution - Make an object : $x = new HTML_Tags() $x->table(array (style => 'mytable', width => '80%').
        $x->tr(
                $x->td(array (width=>'50%'), "Hello").
                $x->td(array (width=>'50%'), "World")
        )
) It's a little more complex and for each function called, the $x instance must be add in "global" declaration. 2nd Solution : Prefix function name By default, all functions are dynamicaly create, so i can prefix them by the name of the package (for the PEAR standard) and let the developper decide to the prefix string ('', 'html' or by default the name of the package). What do you think about theses solutions please ? PS: I have heard the PHP 5 would be add the "[]" alias of the array instruction : [1,2,3] equivalent to array(1,2,3) But i have test the PHP 5 and this doesn't works.. Anybody have informations about this ? Thanks
-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com

« previous php.pear.dev (#26867) next »