note 129386 added to features.commandline.interactive

From: Date: Mon, 08 Apr 2024 08:51:42 +0000
Subject: note 129386 added to features.commandline.interactive
Groups: php.notes 
Request: Send a blank email to php-notes+get-221279@lists.php.net to get a copy of this message
Note that destructors will not be triggered when exiting interactive shell by any method. (Like CTRL + D, CTRL + Z or CTRL + C). Since the interactive shell is effectively a continuous runtime, the "end of script" condition is never met for a destructor to run. And exiting the interactive shell is not considered end of script but rather the end of interpreter process. And since the process is dead; it can't run the destructor. Therefore the only way for a destructor to run is that you remove all the references to the corresponding object. Like: <?php class A { public function __destructor() { // This will never run after ending PHP interactive shell session. } } $a = new A(); // This is the only way for the destructor to be able to run. $a = null; // Or; unset($a); ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.13.131 (proxied: 46.1.2.249) ---- Manual Page -- https://php.net/manual/en/features.commandline.interactive.php Edit -- https://main.php.net/note/edit/129386 Del: integrated -- https://main.php.net/note/delete/129386/integrated Del: useless -- https://main.php.net/note/delete/129386/useless Del: bad code -- https://main.php.net/note/delete/129386/bad+code Del: spam -- https://main.php.net/note/delete/129386/spam Del: non-english -- https://main.php.net/note/delete/129386/non-english Del: in docs -- https://main.php.net/note/delete/129386/in+docs Del: other reasons-- https://main.php.net/note/delete/129386 Reject -- https://main.php.net/note/reject/129386 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221279) next »