|
Posted by Richard Lynch on 01/20/05 21:57
Tim Boring wrote:
> On Thu, 2005-01-20 at 13:41, Jason Wong wrote:
>> On Friday 21 January 2005 01:52, Tim Boring wrote:
>>
>> Well the biggest problem in your code right now is your incomprehensible
>> (to
>> me anyway) use of the switch construct. For a start I've no idea why
>> you're
>> using ...
>>
>> > switch ($line)
>>
>> ... when your tests do not involve $line
>>
>> > case ($total_counter <= 5):
>
> I see your point, but the other tests do involve $line. This one that
> you reference I'm using for a "special need"--basically so I leave in
> the initial column headings from the report, because they would match
> several of the tests that would discard those lines.
My current theory is this:
PHP takes $line and compares it as a scalar to the return value of your
expressions.
Thus, something like:
($total_count <= 5) which returns a BOOLEAN is compared to $line, which,
with AKRN at the front, in boolean turns into 1.
However, when you get to ereg_match, which returns, err?, integer, PHP
type-casts to integer, at which point AKRN turns into 0.
This is what I meant when I said it was just too damn confusing to
mix-n-match a value in the switch ($x) with an expression in the case :
I'd say use expressions with switch (TRUE) or swith ($x) with constants
but don't mix-n-match unless you really want to confuse yourself.
I suppose if *ALL* the variables/expresions are of the same data-type, it
would be Not So Bad since there will be none of the PHP
auto-type-conversion to muddy the waters...
--
Like Music?
http://l-i-e.com/artists.htm
Navigation:
[Reply to this message]
|