[PHP] static variables inside static methods

2011-07-06 Thread Дмитрий Степанов
Hello, everybody. While working with static variables inside static class' methods, I have found this very interesting (at least for me) behavior of PHP. Consider the following class definitions (example #1): class X { public final static function test() { static $i; return ++$i; } } class Y

Re: [PHP] static variables inside static methods

2011-07-06 Thread Andrew Williams
I think you are confusing scope visibility level of the variable within method and the class. Variable within the method is going to 1 because it was declare within the test method and there no link to the one declared outside the test method. The second case is referencing the varible of the

Re: [PHP] static variables inside static methods

2011-07-06 Thread Дмитрий Степанов
The second case is referencing the varible of the class. Maybe you are right. However, I don't really think that there is a true reference to the class var in example #2. PHP documentation of static keywords does not unambiguously explain behavior of static variables inside methods in example

Re: [PHP] static variables inside static methods

2011-07-06 Thread David Harkness
2011/7/6 Дмитрий Степанов dmit...@stepanov.lv PHP documentation of static keywords does not unambiguously explain behavior of static variables inside methods in example #1. I believe that in example #1 the exactly same instance of function (method) is used irregarding of how you call it

RE: [PHP] static variables

2006-02-10 Thread Miguel Guirao
de 2006 12:45 a.m. To: php-general@lists.php.net Cc: suresh kumar Subject: Re: [PHP] static variables Suresh, You could use the link to pass your variable to the next page, or to the same page: Instead of $count=0; use if (!isset($_GET['count'])) $count=0; Then for your link use print

[PHP] static variables

2006-02-09 Thread suresh kumar
hai everbody i am facing a problem with static variable. i declared $count=0 as Static variable,when i click the link specified in anchor tag my page is refreshed again and static variable lose its value and assigned with 0.i want the logic code say my stsic variable will not lose

Re: [PHP] static variables

2006-02-09 Thread Hugh Danaher
['PHP_SELF'].?count=$countlink to same page/a if you want to return to the same page with an updated count. HTH HTD - Original Message - From: suresh kumar [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Thursday, February 09, 2006 9:50 PM Subject: [PHP] static variables hai everbody