note 61657 deleted from language.oop5.cloning by danielc

From: Date: Sun, 27 Jul 2008 05:28:26 +0000
Subject: note 61657 deleted from language.oop5.cloning by danielc
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-142800@lists.php.net to get a copy of this message
Note Submitter: ove at junne dot dk Reason: 1 ---- Consider this: function myfunc() { $A = new myobject(); // Create another mysql connection $A->method1(); // Runs a query (works) } $A = new myobject(); // Create a mysql connection myfunc(); $A->method1(); // This query fails! Possible because leaving the function has closed the connection. Conclusion: Declaration of objects within and outside a function WITH THE SAME NAME, will affect each other. Do not relay on the rules of scope. Take care when using recursive structures!! It took me a long time to figure out.

« previous php.notes (#142800) next »