how to say "inverse your value" (to a boolean)?
am 11.08.2009 00:16:59 von Govindaquick 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
$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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 00:33:30 von Tony MarstonTry $tableRowBGcolorBoolCounter = !$tableRowBGcolorBoolCounter --0016e6470f2e9e40ba0470d1499c > = ! with XOR John Butler wrote: NO! For the love of God and all that is holy, don't do that accumulator / --0016e64650a054fb3f0470d2eecf ummmm... Then YOU have more aggressive error_reporting than the default setting > echo "something " . (($a = $a^1) ? "red\n" : "green\n"); http://us3.php.net/manual/en/language.operators.comparison.p hp Pretty much the best operator ever invented IMHO. And Since PHP 5.3, it = No...not zerowing...no... On Mon, Aug 10, 2009 at 04:18:29PM -0700, Daevid Vincent wrote: Daevid Vincent wrote: > -----Original Message----- 2009/8/11 Daevid Vincent On Tue, 2009-08-11 at 11:28 +0100, David Otton wrote: seems they changing idears on the fly? could it be that the designer is a At 4:16 PM -0600 8/10/09, John Butler wrote: At 8:46 AM -0400 8/11/09, tedd wrote: --0016364ed61c1f6dc40470dda94e >>>> quick Q: At 2:29 PM +0100 8/11/09, Conor Mac Aoidh wrote: At 10:27 AM -0300 8/11/09, Martin Scotta wrote: --001517741bbc0a34570470e1de57 Ben Dunlap wrote: --0016e646a34e58b57a0470e27c19 What a lot of good ideas spawned from the OP! At 1:53 PM -0600 8/11/09, John Butler wrote: >> What a lot of good ideas spawned from the OP! John Butler wrote: > He's pointing out a typo... "forearch" instead of "foreach" :) > -----Original Message----- Daevid Vincent wrote: At 8:33 AM -0700 8/12/09, Jim Lucas wrote: thats why I decided years ago to write myself a little bunch of classes for
Notice that it says '= !' instead of !='.
--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
"John Butler"
news:52842D6F-DD45-44A6-AE06-2E58EF8F6D8E@gmail.com...
> 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 '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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 00:41:32 von Martin Scotta
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
You can do this...
for( $b=true;
{
}
I usually use this solution....
$types = array( 'one', 'two' );
foreach( $list as $item ) # <-- your set of (many) items
{
echo current( $types ); # <-- this prints the current class
# code
next( $types ) or reset( $types ); # and this do the magic
}
Hey! look, this solution can work with more than 2 types...
try it with many types: $types = array( 'one', 'two', three', 'four' );
On Mon, Aug 10, 2009 at 7:16 PM, John Butler
> 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 '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 General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Martin Scotta
--0016e6470f2e9e40ba0470d1499c--
Re: Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 00:48:07 von Govinda
!
=)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.phpRe: how to say "inverse your value" (to a boolean)?
am 11.08.2009 00:50:47 von Ralph Deffke
try this
$a = 0;
echo $a ^ 1;
$a = 1;
echo $a ^ 1;
hope that helps
ralph
ralph_deffke@yahoo.de
"John Butler"
news:52842D6F-DD45-44A6-AE06-2E58EF8F6D8E@gmail.com...
> 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 '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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 01:03:13 von List Manager
> 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 '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
>
>
$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
RE: how to say "inverse your value" (to a boolean)?
am 11.08.2009 01:18:29 von Daevid Vincent
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) {
?>">
}= $foo
?>
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@cmsws.com]
> Sent: Monday, August 10, 2009 4:03 PM
> To: John Butler
> Cc: PHP-General List
> Subject: Re: [PHP] 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 '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
> >
> >
>
>
>
> $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
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 02:39:10 von Martin Scotta
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
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
> 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) {
> ?>">
> }= $foo
> ?>
>
> 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@cmsws.com]
> > Sent: Monday, August 10, 2009 4:03 PM
> > To: John Butler
> > Cc: PHP-General List
> > Subject: Re: [PHP] 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 '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
> > >
> > >
> >
> >
> >
> > $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
--0016e64650a054fb3f0470d2eecf--
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 02:44:47 von Ralph Deffke
try
echo "";
";
for( $i=0 ; $i<10; $i++){
echo "something " . (($a = $a^1) ? "red\n" : "green\n");
}
echo "
watchout the brackets !
cheers
ralph_deffke@yahoo.de
"John Butler"
news:52842D6F-DD45-44A6-AE06-2E58EF8F6D8E@gmail.com...
> 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 '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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: how to say "inverse your value" (to a boolean)?
am 11.08.2009 03:19:10 von Daevid Vincent
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@gmail.com]
> Sent: Monday, August 10, 2009 5:39 PM
> To: Daevid Vincent
> Cc: PHP-General List
> Subject: Re: [PHP] 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
>
>
> > 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) {
> > ?>
> ?>"> = $foo
> > ?>
> >
> > 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@cmsws.com]
> > > Sent: Monday, August 10, 2009 4:03 PM
> > > To: John Butler
> > > Cc: PHP-General List
> > > Subject: Re: [PHP] 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 '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
> > > >
> > > >
> > >
> > >
> > >
> > > $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
Re: Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 03:27:19 von Govinda
Re: The "?" char in this ^^^^ line above..
where in the php docs can I read about what that is doing?
I have not come across this construct before today, from you guys.
thanks
-John
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.phpRe: Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 03:41:06 von Adam Randall
Find "Ternary" on that page.
It's a shortened conditional:
cond ? true : false
Adam.
On Mon, Aug 10, 2009 at 6:27 PM, John
Butler
>> Â echo "something " . (($a =3D $a^1) ? "red\n" : "green\n");
>
> Re: The "?" char in this ^^^^ line above..
> where in the php docs can I read about what that is doing?
> I have not come across this construct before today, from you guys.
>
> thanks
> -John
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--=20
Adam Randall
http://www.xaren.net
AIM: blitz574
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.phpRE: Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 03:59:34 von Daevid Vincent
is
possible to leave out the middle part of the ternary operator. =
Expression
expr1 ?: expr3 returns expr1 if expr1 evaluates to TRUE, and expr3
otherwise. Awesome!
Also, Adam Randall set up us the bomb. ;-)
(http://www.youtube.com/watch?v=3DqItugh-fFgg)
> -----Original Message-----
> From: Adam Randall [mailto:randalla@gmail.com]=20
> Sent: Monday, August 10, 2009 6:41 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Re: how to say "inverse your value" (to a boolean)?
>=20
> http://us3.php.net/manual/en/language.operators.comparison.p hp
>=20
> Find "Ternary" on that page.
>=20
> It's a shortened conditional:
>=20
> cond ? true : false
>=20
> Adam.
>=20
> On Mon, Aug 10, 2009 at 6:27 PM, John
> Butler
> >> =A0echo "something " . (($a =3D $a^1) ? "red\n" : "green\n");
> >
> > Re: The "?" char in this ^^^^ line above..
> > where in the php docs can I read about what that is doing?
> > I have not come across this construct before today, from you guys.
> >
> > thanks
> > -John
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>=20
>=20
>=20
> --=20
> Adam Randall
> http://www.xaren.net
> AIM: blitz574
>=20
> --=20
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>=20
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.phpRe: Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 04:11:14 von Adam Randall
But yes, the ternary operator is the bomb, which you can get carried
away with. Daevid knows what I mean :)
Adam.
On Mon, Aug 10, 2009 at 6:59 PM, Daevid Vincent
> Pretty much the best operator ever invented IMHO. And Since PHP 5.3, it i=
s
> possible to leave out the middle part of the ternary operator. Expression
> expr1 ?: expr3 returns expr1 if expr1 Â evaluates to TRUE, and expr3
> otherwise. Awesome!
>
> Also, Adam Randall set up us the bomb. ;-)
> (http://www.youtube.com/watch?v=3DqItugh-fFgg)
>
>> -----Original Message-----
>> From: Adam Randall [mailto:randalla@gmail.com]
>> Sent: Monday, August 10, 2009 6:41 PM
>> To: php-general@lists.php.net
>> Subject: Re: [PHP] Re: how to say "inverse your value" (to a boolean)?
>>
>> http://us3.php.net/manual/en/language.operators.comparison.p hp
>>
>> Find "Ternary" on that page.
>>
>> It's a shortened conditional:
>>
>> cond ? true : false
>>
>> Adam.
>>
>> On Mon, Aug 10, 2009 at 6:27 PM, John
>> Butler
>> >> Â echo "something " . (($a =3D $a^1) ? "red\n" : "green\n");
>> >
>> > Re: The "?" char in this ^^^^ line above..
>> > where in the php docs can I read about what that is doing?
>> > I have not come across this construct before today, from you guys.
>> >
>> > thanks
>> > -John
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>>
>>
>>
>> --
>> Adam Randall
>> http://www.xaren.net
>> AIM: blitz574
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
--=20
Adam Randall
http://www.xaren.net
AIM: blitz574
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.phpRe: how to say "inverse your value" (to a boolean)?
am 11.08.2009 04:18:02 von Paul M Foster
> 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) {
> ?>">
> }= $foo
> ?>
NO! For the love of God and all that is holy, don't do that = "hack".
That's sooooo 1990's.
Just do this. It's quick and simple:
">
(I just couldn't resist! ;-)
Paul
--
Paul M. Foster
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 06:09:46 von List Manager
> 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) {
> ?>">
= $foo
> ?>
Wow, were to start with all the problems in the above code:
1. Short tags?
2. Not using echo or print. You actually recommend breaking in/out of php?
3. Using uninitialized variables (I run with the E_ALL crowd)
4. Using the and not the ... Hmmm
> }
>
> 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@cmsws.com]
>> Sent: Monday, August 10, 2009 4:03 PM
>> To: John Butler
>> Cc: PHP-General List
>> Subject: Re: [PHP] 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 '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
>>>
>>>
>>
>>
>> $arr = range(1, 10);
>>
>> $i = 0;
>> foreach ( $arr AS $row ) {
>>
>> $row_color = ( ( $i++ % 2 ) ? 'green' : 'red');
>>
>> echo $row_color;
>>
>> }
>>
>> ?>
>>
another (neat|strange)+ way I use the above is like so
$arr = range(1, 10);
$i = 0;
foreach ( $arr AS $row ) {
echo ' ';'.$row.'
}
?>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: how to say "inverse your value" (to a boolean)?
am 11.08.2009 11:53:36 von M.Ford
> From: Daevid Vincent [mailto:daevid@daevid.com]
> Sent: 11 August 2009 02:19
>=20
> 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...
>=20
> http://us2.php.net/manual/en/function.error-reporting.php
>=20
> // Report all errors except E_NOTICE
> // This is the default value set in php.ini
> error_reporting(E_ALL ^ E_NOTICE);
Yes, but recent versions also have the following recommended settings:
; error_reporting
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
; display_errors
; Development Value: On
; Production Value: Off
Cheers!
Mike
--=20
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,
Leeds Metropolitan University, C507, Civic Quarter Campus,=20
Woodhouse Lane, LEEDS,=A0 LS1 3HE,=A0 United Kingdom=20
Email: m.ford@leedsmet.ac.uk=20
Tel: +44 113 812 4730
To view the terms under which this email is distributed, please go to http:=
//disclaimer.leedsmet.ac.uk/email.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.phpRe: how to say "inverse your value" (to a boolean)?
am 11.08.2009 12:28:21 von David Otton
> 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:
> =A0 =A0 =A0 =A0.dataRow1 { background-color: #DFDFDF; }
> =A0 =A0 =A0 =A0.dataRow2 { background-color: #FFFFFF; }
>
> foreach ($foo_array as $foo) {
> =A0 ?>">
> }
>=3D $foo
> ?>
A change request just came in - the interaction designer wants every
third line to have a grey background, instead of every second line.
> 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 cl=
ass
Um. No. Just no.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.phpRe: how to say "inverse your value" (to a boolean)?
am 11.08.2009 12:37:15 von Ashley Sheridan
> 2009/8/11 Daevid Vincent
>
> > 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) {
> > ?>">
> > }= $foo
> > ?>
>
> A change request just came in - the interaction designer wants every
> third line to have a grey background, instead of every second line.
>
> > 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
>
> Um. No. Just no.
>
I tend to do something like this:
$count = 0;
foreach($foo_array as $foo)
{
$class = ($count % 3 == 0)?'class="thirdRow"':'';
print " ";$foo
}
You only need to give one row the class, as you style up all the rows
and only change the row that needs to change.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.phpRe: how to say "inverse your value" (to a boolean)?
am 11.08.2009 12:38:50 von Ralph Deffke
smal ugly person while u a a good looking ladykiller ?
on that background I would design a function where u can change ti what ever
u want on the fly something like this
var $a;
function alternate( $a, $_b=array( "red", "red" ,"green" ,... ) {
if( count( $_b ) > $a ) {
return $_b[ $a++ ] ;
}
$a=0;
return $_b[ $a++ ] ;
}
so now u can do what ever anybody wants on just putting the right values
into the array
cheers
ralph
ralph_deffke@yahoo.de
"David Otton"
news:193d27170908110328p43b4722fkc46b0bcda97fcf48@mail.gmail .com...
2009/8/11 Daevid Vincent
> 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) {
> ?>">
> }= $foo
> ?>
A change request just came in - the interaction designer wants every
third line to have a grey background, instead of every second line.
> 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
Um. No. Just no.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.phpRe: how to say "inverse your value" (to a boolean)?
am 11.08.2009 14:46:08 von TedD
>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 '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
John:
Here's my solution:
http://webbytedd.com/b/color-rows/
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 15:09:25 von TedD
>At 4:16 PM -0600 8/10/09, 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 '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
>
>John:
>
>Here's my solution:
>
>http://webbytedd.com/b/color-rows/
>
>Cheers,
>
>tedd
However, my solution (after reading others) is for an alternating row
color (a boolean operation).
The problem was NOT making every third row a different color or
making every row a different color. Those problems would require
different solutions.
There is nothing wrong with embedding php within html, which is
really a misnomer because it's the php interpreter that's sending the
resultant html to the browser. It is not sending php snip-its for the
browser to handle. So, embedding code such as:
Is a valid statement that works. It would be nice if you initialize
the $i value, but it will work either way.
My solution, provided via the above link, is a valid solution.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 15:27:14 von Martin Scotta
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
On Tue, Aug 11, 2009 at 10:09 AM, tedd
> At 8:46 AM -0400 8/11/09, tedd wrote:
>
>> At 4:16 PM -0600 8/10/09, 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 '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
>>>
>>
>> John:
>>
>> Here's my solution:
>>
>> http://webbytedd.com/b/color-rows/
>>
>> Cheers,
>>
>> tedd
>>
>
> However, my solution (after reading others) is for an alternating row color
> (a boolean operation).
>
> The problem was NOT making every third row a different color or making
> every row a different color. Those problems would require different
> solutions.
>
> There is nothing wrong with embedding php within html, which is really a
> misnomer because it's the php interpreter that's sending the resultant html
> to the browser. It is not sending php snip-its for the browser to handle.
> So, embedding code such as:
>
>
>
> Is a valid statement that works. It would be nice if you initialize the $i
> value, but it will work either way.
>
> My solution, provided via the above link, is a valid solution.
>
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
A change request just came in - the interaction designer wants every
third line to have a grey background, instead of every second line.
# before was $styles = array( 'even', 'odd' );
# after new requirements it is...
$styles = array( 'white', 'white', 'gray' );
foreach($items as $item)
{
printf( '
next( $styles ) or reset( $styles );
}
The simplest solution is always the best choice.
This provides maintainability and flexibility to changes ( that we don't
know yet )
--
Martin Scotta
--0016364ed61c1f6dc40470dda94e--
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 15:29:57 von Conor Mac Aoidh
>>>> I have this inside a foreach{} that I want to alternate between on
>>>> and
>>>> off so I can alternate the background-color of my '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
If I was going to do that then I would use jQuery:
And yes I know that this is a PHP mailing list lol
--
Conor
http://conormacaoidh.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 16:10:46 von TedD
>>>>>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 '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
>
>If I was going to do that then I would use jQuery:
>
>
>
>And yes I know that this is a PHP mailing list lol
>
>--
>Conor
And if javascript is turned off?
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 16:13:07 von TedD
>A change request just came in - the interaction designer wants every
>third line to have a grey background, instead of every second line.
>
># before was $styles = array( 'even', 'odd' );
># after new requirements it is...
>$styles = array( 'white', 'white', 'gray' );
>foreach($items as $item)
>{
>
>printf( '
>
>next( $styles ) or reset( $styles );
>
>}
>
>The simplest solution is always the best choice.
>This provides maintainability and flexibility to changes ( that we
>don't know yet )
>
>--
>Martin Scotta
The "simplest solution" is in the eyes of the beholder.
My solution was the simplest for the problem presented.
You presented a different problem with a different solution.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 20:28:21 von Ben Dunlap
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
> # before was $styles = array( 'even', 'odd' );
> # after new requirements it is...
> $styles = array( 'white', 'white', 'gray' );
> foreach($items as $item)
> {
> printf( '
>
> next( $styles ) or reset( $styles );
> }
>
>
+5000. I think is by far the most readable and flexible solution suggested.
I also like it because it's PHPish -- it uses the features of the language
that were made-to-order for this problem.
Ben
--001517741bbc0a34570470e1de57--
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 20:57:49 von Robert Cummings
>> # before was $styles = array( 'even', 'odd' );
>> # after new requirements it is...
>> $styles = array( 'white', 'white', 'gray' );
>> foreach($items as $item)
>> {
>> printf( '
>>
>> next( $styles ) or reset( $styles );
>> }
>>
>>
> +5000. I think is by far the most readable and flexible solution suggested.
> I also like it because it's PHPish -- it uses the features of the language
> that were made-to-order for this problem.
Actually it's the wrong way to do it.
Change the class names to "alternate1" and "alternate2" (or something
else meaningful without being tied to a definition). That way when you
set the colour for style "white" to "green" it doesn't result in
confusion. Seriously though... this is nomenclature 101.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 21:12:37 von Ben Dunlap
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
> # before was $styles = array( 'even', 'odd' );
>>> # after new requirements it is...
>>> $styles = array( 'white', 'white', 'gray' );
>>> foreach($items as $item)
>>> {
>>> printf( '
>>>
>>> next( $styles ) or reset( $styles );
>>> }
>>>
>>>
>>> +5000. I think is by far the most readable and flexible solution
>> suggested.
>> I also like it because it's PHPish -- it uses the features of the language
>> that were made-to-order for this problem.
>>
>
> Actually it's the wrong way to do it.
>
> Change the class names to "alternate1" and "alternate2" (or something else
> meaningful without being tied to a definition). That way when you set the
> colour for style "white" to "green" it doesn't result in confusion.
> Seriously though... this is nomenclature 101.
Good point, and thanks for the presentation-vs-content reality check. I'll
downgrade my vote to a more sober +4990, in consideration of the class names
in $styles.
Ben
--0016e646a34e58b57a0470e27c19--
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 21:53:54 von Govinda
I am learning many things,.. while also actually working (paying
bills), so I regularly have to just go with what I know well.
Anyway, I already have the forearch { loop (for other reasons it is
necessary), and I only needed one color to alternate with the default
white.. so I used this:
forearch { ...
$tableRowBGcolorBoolCounter = !$tableRowBGcolorBoolCounter; //-boolean
on and off
(which then sticks in one CSS class or another for that .
thanks for everyone's feedback.
-John
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 22:00:18 von TedD
>What a lot of good ideas spawned from the OP!
>I am learning many things,.. while also actually working (paying
>bills), so I regularly have to just go with what I know well.
>
>Anyway, I already have the forearch { loop (for other reasons it is
>necessary), and I only needed one color to alternate with the
>default white.. so I used this:
>
> forearch { ...
>$tableRowBGcolorBoolCounter = !$tableRowBGcolorBoolCounter;
>//-boolean on and off
>
>(which then sticks in one CSS class or another for that .
>
>thanks for everyone's feedback.
>-John
Yeah, but forearch ain't going to work.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 22:08:16 von Govinda
>> I am learning many things,.. while also actually working (paying
>> bills), so I regularly have to just go with what I know well.
>>
>> Anyway, I already have the forearch { loop (for other reasons it is
>> necessary), and I only needed one color to alternate with the
>> default white.. so I used this:
>>
>> forearch { ...
>> $tableRowBGcolorBoolCounter = !$tableRowBGcolorBoolCounter; //-
>> boolean on and off
>>
>> (which then sticks in one CSS class or another for that .
>> Wow, were to start with all the problems in the above code:
>>
>> thanks for everyone's feedback.
>> -John
>
> Yeah, but forearch ain't going to work.
what do you mean? I must have neglected to include more of the
relevant code to show you that it IS working just fine. I will
certainly explain more if you ask.. but the whole point of me
starting the thread was just to be reminded how to inverse a boolean
var's value. Tony answered me; I am happy. I assume you don't want
me (the newbie) to show how I have it working. (?)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 22:13:10 von Robert Cummings
>>> What a lot of good ideas spawned from the OP!
>>> I am learning many things,.. while also actually working (paying
>>> bills), so I regularly have to just go with what I know well.
>>>
>>> Anyway, I already have the forearch { loop (for other reasons it is
>>> necessary), and I only needed one color to alternate with the
>>> default white.. so I used this:
>>>
>>> forearch { ...
>>> $tableRowBGcolorBoolCounter = !$tableRowBGcolorBoolCounter; //-
>>> boolean on and off
>>>
>>> (which then sticks in one CSS class or another for that .
>
>>>
>>> thanks for everyone's feedback.
>>> -John
>> Yeah, but forearch ain't going to work.
>
>
> what do you mean? I must have neglected to include more of the
> relevant code to show you that it IS working just fine. I will
> certainly explain more if you ask.. but the whole point of me
> starting the thread was just to be reminded how to inverse a boolean
> var's value. Tony answered me; I am happy. I assume you don't want
> me (the newbie) to show how I have it working. (?)
He's pointing out a typo... "forearch" instead of "foreach" :)
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: how to say "inverse your value" (to a boolean)?
am 11.08.2009 22:17:18 von Govinda
LOL!
I almost always miss the jokes.
Thanks for the smiley face to get my (lighter) attention ;-)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.phpRE: how to say "inverse your value" (to a boolean)?
am 11.08.2009 23:15:21 von Daevid Vincent
> Daevid Vincent 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) {
> > ?>
> ?>"> = $foo
> > ?>
> Wow, were to start with all the problems in the above code:
> 1. Short tags?
Nothing wrong with them. Do yourself a test. There is zero speed difference
in a page. It makes your code cleaner and easier to read, plus less
kilobytes you have to pull from the hard drive, therefore faster pages.
http://stackoverflow.com/questions/662891/is-there-a-speed-d ifference-betwee
n-php-echo-var-and-var
http://cubicspot.blogspot.com/2009/06/maximum-failure-php-6- deprecates-short
..html
Are you sure you're not confused with "short_open_tags" ie. ?> -- which I
am fully against (as am I against <% %> too), although sadly they are lumped
into the same directive, when IMHO they should be separate.
http://us.php.net/manual/en/ini.core.php#ini.short-open-tag
http://www.php.net/~derick/meeting-notes.html#remove-support -for-and-script-
language-php-and-add-php-var
> 2. Not using echo or print.
= ?> is a fantastic shortcut to the antiquated B.S.
The vast majority of your page is output in little fragments like this, so
why not keep it clean and easy to read. Why would you purposely choose to be
more verbose than you need to be for something as basic as "print".
> You actually recommend breaking in/out of php?
Hell yeah I do. THAT is one of the MAIN reasons to use PHP. Otherwise, why
not just render your whole page with a bunch of $html .= '...';
tags and print $html at the end. Welcome to the year 2000 my friend.
You're probably the same kind of person that does this crap:
if ($foo == true)
{
echo "A";
}
else
{
echo "B";
}
(complete with extra braces and checking for 'true' explicitly, but not
using === in such cases)
Rather than a much cleaner, easier to read/write and more concise:
= ($foo) ? 'A' : 'B' ?>
> 3. Using uninitialized variables (I run with the E_ALL crowd)
I'm so happy for you. Do you have a membership card and everything? That's
your own masochistic fault then. I run with the
save-myself-the-headache-and-write-clean-efficient-code crowd.
> 4. Using the and not the ... Hmmm
Maybe you're new to how HTML works, but if you want to highlight a ROW (as
the OP did), then you put the background color on the highest parent that it
applies to. Hey imagine that, there is a TR tag which stands for TABLE ROW
tag. Seems obvious to me. This reduces your page size in kilobytes, makes a
much cleaner HTML rendering to read in source, and is the PROPER way to do
it.
> > }
> >
> > 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@cmsws.com]
> >> Sent: Monday, August 10, 2009 4:03 PM
> >> To: John Butler
> >> Cc: PHP-General List
> >> Subject: Re: [PHP] 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 '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
> >>>
> >>>
> >>
> >>
> >> $arr = range(1, 10);
> >>
> >> $i = 0;
> >> foreach ( $arr AS $row ) {
> >>
> >> $row_color = ( ( $i++ % 2 ) ? 'green' : 'red');
> >>
> >> echo $row_color;
> >>
> >> }
> >>
> >> ?>
> >>
>
> another (neat|strange)+ way I use the above is like so
>
>
>
>
> $arr = range(1, 10);
>
> $i = 0;
>
> foreach ( $arr AS $row ) {
>
> echo ' ';'.$row.'
>
> }
> ?>
>
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >
> >
>
>
> --
> Jim Lucas
>
> "Some men are born to greatness, some achieve greatness,
> and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
> by William Shakespeare
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: how to say "inverse your value" (to a boolean)?
am 12.08.2009 17:33:43 von List Manager
>
>
>> -----Original Message-----
>> Daevid Vincent 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) {
>>> ?>
>> ?>"> = $foo
>>> ?>
>> 1. Short tags?
>
> Nothing wrong with them. Do yourself a test. There is zero speed difference
> in a page. It makes your code cleaner and easier to read, plus less
> kilobytes you have to pull from the hard drive, therefore faster pages.
>
> http://stackoverflow.com/questions/662891/is-there-a-speed-d ifference-betwee
> n-php-echo-var-and-var
>
> http://cubicspot.blogspot.com/2009/06/maximum-failure-php-6- deprecates-short
> .html
>
Looks like all your code is going to stop working when PHP 6 comes
around. Since the "= " is part of the family they look to deprecate.
(read next comment)
> Are you sure you're not confused with "short_open_tags" ie. ?> -- which I
> am fully against (as am I against <% %> too), although sadly they are lumped
> into the same directive, when IMHO they should be separate.
>
> http://us.php.net/manual/en/ini.core.php#ini.short-open-tag
>
> http://www.php.net/~derick/meeting-notes.html#remove-support -for-and-script-
> language-php-and-add-php-var
>
Glad you mention this. If you look at the note for the short-open-tag
option, it says:
Note: This directive also affects the shorthand "= ", which is
identical to " echo ". Use of this shortcut requires short_open_tag
to be on.
So, you are saying you do not like to promote the use of short_open_tag,
but in your examples of how to write your code, you use them because it
shortens your code, etc...
So, which is it, do you like using short_open_tag or not??? Because
"=" is part of the short_open_tag family
>> 2. Not using echo or print.
>
> = ?> is a fantastic shortcut to the antiquated B.S.
Yours requires short_open_tag to be on and uses them, mine doesn't
Plus, I would never do this in side of HTML to begin with. If I was in
the middle of a script, then I would have PHP echo the entire HTML
portion of the code rather then breaking out of PHP - do some HTML -
break in to PHP and echo a variable - break out and finish the HTML.
> The vast majority of your page is output in little fragments like this, so
> why not keep it clean and easy to read. Why would you purposely choose to be
> more verbose than you need to be for something as basic as "print".
>
>> You actually recommend breaking in/out of php?
>
> Hell yeah I do. THAT is one of the MAIN reasons to use PHP. Otherwise, why
> not just render your whole page with a bunch of $html .= '...';
> tags and print $html at the end. Welcome to the year 2000 my friend.
>
So, your example above would tell me that you are the type of guy that
would echo all your HTML code from within your nested php functions? hmmm
Breaking in/out of PHP all the time, what a mess of code that would be.
I have tried tasting that soup before. I didn't like it...
> You're probably the same kind of person that does this crap:
>
> if ($foo == true)
> {
> echo "A";
> }
> else
> {
> echo "B";
> }
>
Actually, my crap would look like this:
if ( $foo ) {
echo 'A';
} else {
echo 'B';
}
No double quotes (no variables need to be worked with)
Open curly bracket on the end of the previous line
I actually wrote a script that will take your example and turn it
into my crap
> (complete with extra braces and checking for 'true' explicitly, but not
> using === in such cases)
>
I do know the difference between == and ===
> Rather than a much cleaner, easier to read/write and more concise:
>
> = ($foo) ? 'A' : 'B' ?>
>
Again with your short_open_tag recommendations... When will you learn
that this is going against what you preach.
>
>> 3. Using uninitialized variables (I run with the E_ALL crowd)
>
> I'm so happy for you. Do you have a membership card and everything? That's
> your own masochistic fault then. I run with the
> save-myself-the-headache-and-write-clean-efficient-code crowd.
>
I don't think I am causing myself any pain.
clean !== use uninitialized variables
efficient !== squelching the NOTICE(s) that get generated by your code
that uses uninitialized variables. Not having them be generate in the
first place would be better.
>> 4. Using the and not the ... Hmmm
>
> Maybe you're new to how HTML works, but if you want to highlight a ROW (as
> the OP did), then you put the background color on the highest parent that it
> applies to. Hey imagine that, there is a TR tag which stands for TABLE ROW
> tag. Seems obvious to me. This reduces your page size in kilobytes, makes a
> much cleaner HTML rendering to read in source, and is the PROPER way to do
> it.
>
I have found, in a number of cases, that using only the tag
doesn't work all the time.
>>> }
>>>
>>> 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@cmsws.com]
>>>> Sent: Monday, August 10, 2009 4:03 PM
>>>> To: John Butler
>>>> Cc: PHP-General List
>>>> Subject: Re: [PHP] 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 '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
>>>>>
>>>>>
>>>>
>>>>
>>>> $arr = range(1, 10);
>>>>
>>>> $i = 0;
>>>> foreach ( $arr AS $row ) {
>>>>
>>>> $row_color = ( ( $i++ % 2 ) ? 'green' : 'red');
>>>>
>>>> echo $row_color;
>>>>
>>>> }
>>>>
>>>> ?>
>>>>
>> another (neat|strange)+ way I use the above is like so
>>
>>
>>
>>
>> $arr = range(1, 10);
>>
>> $i = 0;
>>
>> foreach ( $arr AS $row ) {
>>
>> echo ' ';'.$row.'
>>
>> }
>> ?>
>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>
>>
>> --
>> Jim Lucas
>>
>> "Some men are born to greatness, some achieve greatness,
>> and some have greatness thrust upon them."
>>
>> Twelfth Night, Act II, Scene V
>> by William Shakespeare
>>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: how to say "inverse your value" (to a boolean)?
am 12.08.2009 17:45:20 von TedD
>Daevid Vincent wrote:
-snip-
I side with Jim on this. I never use short tags and write similar crap.
Jim said:
>I have found, in a number of cases, that using only the tag
>doesn't work all the time.
It should work ALL the time, but sometimes inheritance overrides what
you think is happening. In such cases, try adding !important to the
rule and I think you'll see what you expect.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: how to say "inverse your value" (to a boolean)?
am 12.08.2009 18:14:29 von Ralph Deffke
the html tags which gives me the ability to have PHP only code, very nice,
no errors and my outputs dont even need Tidy pure XHTML
i find these idear of mixing html and php as spagetty, using divs for tables
as something what facirs do,
no problems with unexpected header outputs, no small fat grafic designer can
make my live difficult, I can change evrything on the fly.
pure OOP
one final echo $page->toHtml();
put a candle for the invention of OOP ...
better as sex
makes the nights fun
consider this guys
ralph_deffke@yahoo.de
"tedd"
news:p06240800c6a892b12f7c@[192.168.1.100]...
> At 8:33 AM -0700 8/12/09, Jim Lucas wrote:
> >Daevid Vincent wrote:
>
>
> -snip-
>
> I side with Jim on this. I never use short tags and write similar crap.
>
> Jim said:
>
> >I have found, in a number of cases, that using only the tag
> >doesn't work all the time.
>
> It should work ALL the time, but sometimes inheritance overrides what
> you think is happening. In such cases, try adding !important to the
> rule and I think you'll see what you expect.
>
> Cheers,
>
> tedd
>
>
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php