ID: 16857 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Feedback +Status: Closed Bug Type: Feature/Change Request Operating System: Any PHP Version: 4.2.0 New Comment:
I backtraced my sources and I seem to have combined the fact that arithmetic expressions can't be used on static vars, with the short if-statement. Besides the code I submited, I also used: <?php function testint($row=-1) { static $currentrow=-1; $currentrow=($row == -1) ? $currentrow++ : $row; echo "$currentrow\n"; } ?> which didn't increment $currentrow, nor did it issue any warning. When looking for info, I found the user-contributed message: http://www.php.net/manual/en/language.variables.scope.php By [EMAIL PROTECTED], at 10-Dec-2001: static $var = 2+3; //any expression which lead me to believe that also () ? : expressions wouldn' t work, but it's the actual assignment that is ignored. Previous Comments: ------------------------------------------------------------------------ [2002-04-28 20:03:21] [EMAIL PROTECTED] Works fine for me. Can you please add a short and complete example which shows clearly what you're exactly asking for? --Jani ------------------------------------------------------------------------ [2002-04-26 12:09:37] [EMAIL PROTECTED] Would be nice if this worked. But the short syntax isn't accepted for a static var, even it's not in the initial declaration. <?php function sql_num_rows($result) { static $cmd='undefined'; if($cmd == 'undefined') { $cmd=($this->pg_new_api) ? 'pg_num_rows' : 'pg_numrows'; } return @$cmd($result); } ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16857&edit=1