Bug #16245 Updated: Bug with inserting NULLs using ibase_prepare()/ibase_execute()

From: Date: Sun, 24 Mar 2002 19:26:08 +0000
Subject: Bug #16245 Updated: Bug with inserting NULLs using ibase_prepare()/ibase_execute()
References: 1  Groups: php.bugs php.doc 
Request: Send a blank email to php-bugs+get-3242@lists.php.net to get a copy of this message
ID: 16245 Updated by: flying@dom.natm.ru -Summary: Static variables into class member funtions have wrong scope Reported By: flying@dom.natm.ru Status: Open Bug Type: Documentation problem -Operating System: Windows 2000 +Operating System: Windows 2000 Server -PHP Version: 4.1.1 +PHP Version: 4.0.6 New Comment: > I guess this is expected behaviour. I can't agree with it. If there is two separate instances of a class - they must have no common variables, but they have. > Reclassified as a documentation problem. > (BTW you can use global $cnt to overcome this problem) No, problem can be solved by having member variable instead of static. Previous Comments: ------------------------------------------------------------------------ [2002-03-24 14:22:08] sander@php.net I guess this is expected behaviour. Reclassified as a documentation problem. (BTW you can use global $cnt to overcome this problem) ------------------------------------------------------------------------ [2002-03-24 11:28:51] flying@dom.natm.ru Static variables inside member functions of a classes have wrong scope. They should belong to each instance of a class, like normal class properties, but they're belong to class definition instead and, therefore, shared between every instance of this class. It makes static variables unusable into class member variables. Here is an example: // Define class class A { var $id = null; function A($id) { $this->id = $id; } function func() { // Here we have counter into static variable static $cnt; if (!$cnt) $cnt = 0; // Show counter value and ID of a class instance echo $this->id.": ".($cnt++)."\n"; } }; // Create 2 instances of our class with different IDs $a = new A('A'); $b = new A('B'); // Call method of each class instance twice and see, // what will happen $a->func(); $b->func(); $a->func(); $b->func(); Expected results: ----------------- A: 0 B: 0 A: 1 B: 1 Actual results: --------------- A: 0 B: 1 A: 2 B: 3 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16245&edit=1

« previous php.bugs (#3242) next »