RE: how to say "inverse your value" (to a boolean)?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Then YOU have more aggressive error_reporting than the default setting
turned on. You might consider turning it down a notch. NOTICEs are basically
useless and bloat your code IMHO -- and apparently the PHP devs too as per
this...

http://us2.php.net/manual/en/function.error-reporting.php

// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);

Don't tell me what to do! You're not my father! ;-)

http://daevid.com

"Some people, when confronted with a problem, think 'I know, I'll use XML.'"
Now they have two problems. 

> -----Original Message-----
> From: Martin Scotta [mailto:martinscotta@xxxxxxxxx] 
> Sent: Monday, August 10, 2009 5:39 PM
> To: Daevid Vincent
> Cc: PHP-General List
> Subject: Re:  how to say "inverse your value" (to a boolean)?
> 
> Use...
> 
> $dr = !$dr
> 
> if you want....
> 
> Notice: Undefined variable: dr
> 
> All variables MUST be initialized before using.
> If you PHP does not complains about it you should read about 
> error_reporting
> 
> On Mon, Aug 10, 2009 at 8:18 PM, Daevid Vincent 
> <daevid@xxxxxxxxxx> wrote:
> 
> > NO! For the love of God and all that is holy, don't do that 
> accumulator /
> > mod "hack".
> > That's sooooo 1980's. And why make the CPU do all that math 
> for every
> > row...
> >
> > Just do this. It's quick and simple:
> >
> > CSS:
> >        .dataRow1 { background-color: #DFDFDF; }
> >        .dataRow2 { background-color: #FFFFFF; }
> >
> > foreach ($foo_array as $foo) {
> >   ?><tr class="<?= ($dr = !$dr) ? "dataRow1" : "dataRow2" 
> ?>"><td><?= $foo
> > ?></td></tr><?php
> > }
> >
> > No need to initialize $dr as by default PHP will make it a 
> boolean "false",
> > then each itteration, it will toggle true/false and 
> substitute the CSS
> > class
> >
> > > -----Original Message-----
> > > From: Jim Lucas [mailto:lists@xxxxxxxxx]
> > > Sent: Monday, August 10, 2009 4:03 PM
> > > To: John Butler
> > > Cc: PHP-General List
> > > Subject: Re:  how to say "inverse your value" (to a boolean)?
> > >
> > > John Butler wrote:
> > > > quick Q:
> > > > I have this inside a foreach{}  that I want to alternate
> > > between on and
> > > > off so I can alternate the background-color of my <tr>'s.
> > > >
> > > > $tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter;
> > > //-boolean
> > > > on and off
> > > >
> > > > I am looking thru' docs and books, but can't remember (nor
> > > find now) in
> > > > PHP how to say "inverse your value" (to a boolean).
> > > > ?
> > > >
> > > > TIA! -G
> > > >
> > > >
> > >
> > > <?php
> > >
> > > $arr = range(1, 10);
> > >
> > > $i = 0;
> > > foreach ( $arr AS $row ) {
> > >
> > >       $row_color = ( ( $i++ % 2 ) ? 'green' : 'red');
> > >
> > >       echo $row_color;
> > >
> > > }
> > >
> > > ?>
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> 
> -- 
> Martin Scotta
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux