note 61657 added to language.oop5.cloning

From: Date: Wed, 08 Feb 2006 16:02:58 +0000
Subject: note 61657 added to language.oop5.cloning
Groups: php.notes 
Request: Send a blank email to php-notes+get-103317@lists.php.net to get a copy of this message
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. ---- Server IP: 194.239.128.8 Probable Submitter: 86.52.156.6 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.cloning.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+61657 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61657&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61657&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61657&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61657&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61657&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61657&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61657&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+61657&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#103317) next »