Re: Prefix function name problem
| From: | Guillaume Lecanu | Date: | Wed, 31 Mar 2004 07:28:55 +0000 |
| Subject: | Re: Prefix function name problem | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-26888@lists.php.net to get a copy of this message | ||
Le mar 30/03/2004 à 03:16, Alan Knowles a écrit :
> I think HTML_Table does something like this. - interesting idea though -
The HTML_Table make table easily.
My lib make all tags functions ( head(), body(), span().. ) for writing
a valid HTML page.
> I thought __call() + overload may be a very interesting way to implement
> this..
I'm going to see the doc about this.
>
> it might be interesting to play around adding it to
> HTML_Template_Flexy_Element..
yes i think is a better way but only is the functions name are short
like "body()" and not "HTML_Tags_body()" or "$x->body()"
>
> 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
> >
>