note 82177 added to language.oop5

From: Date: Sun, 30 Mar 2008 15:49:22 +0000
Subject: note 82177 added to language.oop5
Groups: php.notes 
Request: Send a blank email to php-notes+get-137760@lists.php.net to get a copy of this message
Sometimes you just forget to close handles, links, etc and sometimes you are just lazy to do that. PHP 5 OOP can do it automatically by using destructors: <?php class MySqlDriver { private $_Link; public function __construct( <...> ) { $this->_Link = mysql_connect( <...> ); } // this will be called automatically at the end of scope public function __destruct() { mysql_close( $this->_Link ); } } $_gLink = new MySqlDriver( <...> ); // and you don't need to close the link manually ?> ---- Server IP: 193.219.81.76 Probable Submitter: 78.62.123.120 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.php Edit -- https://master.php.net/note/edit/82177 Del: integrated -- https://master.php.net/note/delete/82177/integrated Del: useless -- https://master.php.net/note/delete/82177/useless Del: bad code -- https://master.php.net/note/delete/82177/bad+code Del: spam -- https://master.php.net/note/delete/82177/spam Del: non-english -- https://master.php.net/note/delete/82177/non-english Del: in docs -- https://master.php.net/note/delete/82177/in+docs Del: other reasons-- https://master.php.net/note/delete/82177 Reject -- https://master.php.net/note/reject/82177 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#137760) next »