Richard Lynch wrote:
> On Wed, June 14, 2006 3:28 pm, BBC wrote:
>> I used many functions as template to change the html syntax.
>> this is one of the function as a sample:
>> <?php
>> function
>> tabletag($border="0",$width="100%",$height="100%",$cellpadding =
>> "0",$cellspacing="0",$style="")
>> {
>> print ("<table width=\"$width\" height =\"$height\"
>> border=\"$border\"
>> cellspacing=\"$cellspacing\" cellpadding=\"$cellpadding\"
>> style=\"$style\">");
>> }
>> ?>
>
> Here are the 'cons' to this solution:
>
> 1.
> The developer has to remember the attributes in the order you chose.
>
> There is no friggin' way I'm going to remember that you put
> cellpadding before cellspacing on a day-to-day basis. Sorry.
which is easily countered if one designs the function better,
something like:
function tabletag($args = array())
{
// default values.
$defaults = array(
'border' => 0,
'width' => '100%'
// etc
);
// normalize the args
$args = array_merge($defaults, $args);
$args = array_intersect_key($args, $defaults); // you might not have
this function
// addition arg sanitation...?
// build a table!!!
}
>
> 2.
> If they want the default border, whatever that is, they have to know
> what it is, and provide it, to get the non-default width.
>
> Passing in NULL does not count, as it will not work in PHP5+
did passing NULL is php4 give you the default value defined in the functions
signature declaration? I can't remember it ever doing that?
I always thought it was: pass in NULL, get a NULL [inside the func].
>
> 3.
> You've basically swapped a simple table tag:
> <table border="0" width="100%" ... >
> with an almost equally long and complicated function call:
> tabletag(0, '100%', ...);
>
> So, really, where's the benefit?...
>
> You can just call the function, or you can just type the table tag.
>
> I see no "win' here, personally.
one win could be that it enforces consistent HTML output - so no more
style-de-jour
kind of HTML output.
then again an output filter that uses the Tiny extension will probably do just
as well :-)
>
> Obviously others do see an added value, of course.
>
>> so I don't need to type "<table ....>", just call those functions.
>> and I don't think it works slowly (cause we just set one function for
>> many
>> tables)
>
> If you have enough TABLE tags for the performance to be an issue, then
> the browser willl choke...
>
> However, assuming you have a function for TR and/or TD, then the
> number of rows in a large TABLE could be a serious performance issue.
>
> This is all assuming proper use of TABLE for tabular data and not
> layout, thank you very much CSS weenies :-)
yeeeehaw! ;-)
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php