@bokehAug 09.2006 — #Simpler[code=php]function setClass(){ static $i = 0; return ($i ^= 1) ? 'lightBg' : 'darkBg'; }[/code]But really I believe using a function for something so basic is overkill. The only benefit I see is keeping the variable out of the global scope (which may be helpful depending on context).
@bokehAug 09.2006 — #^ is [URL=http://www.php.net/manual/en/language.operators.bitwise.php]PHP's XOR bitwise operator[/URL] but the manual description is not too easy to follow. A bitwise exclusive OR takes two bit patterns of equal length and performs the logical XOR operation on each pair of corresponding bits. The result in each position is 1 if the two bits are different, and 0 if they are the same. Put in simple language it switchs [I]$i[/I] to the opposite state. So if the value of [I]$i[/I] was [I]zero[/I] it would be switched to [I]one[/I] and vice versa as demonstrated by the following. [code=php]<pre>