4.1.0rc2 register_shutdown_function
| From: | ben woodhead | Date: | Thu, 15 Nov 2001 17:56:40 +0000 |
| Subject: | 4.1.0rc2 register_shutdown_function | ||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-3864@lists.php.net to get a copy of this message | ||
Hello Everybody
have been looking at register_shutdown_function() inside a class and it works
fine with 4.0.x, but does not work in 4.1.0rc2... Am I doing something wrong
or is it a bug.. It seems to be descructing the class before it runs the
function, causing this error:
Warning: Unable to call (null)() - function does not exist in Unknown on line
0
There is the class
Thanks Ben
--
Windows taught me that there are some problems that can't be solved.
Linux taught me that when it starts working, stop asking questions!
<?php /******************************************************************************* Copyright Notice phpEchoAPI, an object-oriented web development Application Programming Interface. Copyright (C) 2001 echotech.ca This Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation either version 2.1 of the License, or any later version. . This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. . You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA . Echotech C/O Eastern Co-Operative Health Organization 129 Kent Street, Suite 304 Charlottetown, PEI, Canada C1A 1N4 *******************************************************************************/ class cErrorV1 { var $m_fileLink = 0; var $m_filename = ""; function cErrorV1($file="") { global $preferences; // Set desctructor to make sure file link is released register_shutdown_function($this->destroyObject); $this->m_fileLink = fopen($preferences["api"]["logs"]."error.log","a"); if(!$this->m_fileLink) { $this->m_fileLink = fopen($preferences["api"]["logs"]."error.log","w"); if (!$this->m_fileLink) { die("Unable to write to error log, Please contact your administrator"); } } if (!empty($file)) { $this->setFile($file); } } function setFile($file) { if (empty($file)) { $this->msg("Did not pass file name"); $this->m_filename = "NO FILE GIVEN"; } else { $this->m_filename = $file; } } function msg($mesg,$line=0) { fputs($this->m_fileLink, date("Y-M-d D G:i "). "Message: ".$mesg.chr(13).chr(10). "File: ".$this->m_filename.chr(13).chr(10). "Line Number: ".$line.chr(13).chr(10).chr(13).chr(10)); echo "<BR>".date("Y-M-d D G:i")." Error Message: $mesg<BR>File Name: ".$this->m_filename." Line Number: $line<BR>"; } function halt($mesg,$error=0,$line=0) { fputs($this->m_fileLink, date("Y-M-d D G:i"). "Message: ".$mesg.chr(13).chr(10). "File: ".$this->m_filename.chr(13).chr(10). "Line Number: ".$line.chr(13).chr(10).chr(13).chr(10)); die("<BR>".date("Y-M-d D G:i")." Error Message: $error - $mesg<BR>File Name: ".$this->m_filename." Line Number: $line<BR>"); } function destroyObject() { if($this->m_fileLink) { fclose($this->m_fileLink); } } } // End Class Declaration ?>
<?php /******************************************************************************* Copyright Notice phpEchoAPI, an object-oriented web development Application Programming Interface. Copyright (C) 2001 echotech.ca This Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation either version 2.1 of the License, or any later version. . This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. . You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA . Echotech C/O Eastern Co-Operative Health Organization 129 Kent Street, Suite 304 Charlottetown, PEI, Canada C1A 1N4 *******************************************************************************/ class cErrorV1 { var $m_fileLink = 0; var $m_filename = ""; function cErrorV1($file="") { global $preferences; // Set desctructor to make sure file link is released register_shutdown_function($this->destroyObject); $this->m_fileLink = fopen($preferences["api"]["logs"]."error.log","a"); if(!$this->m_fileLink) { $this->m_fileLink = fopen($preferences["api"]["logs"]."error.log","w"); if (!$this->m_fileLink) { die("Unable to write to error log, Please contact your administrator"); } } if (!empty($file)) { $this->setFile($file); } } function setFile($file) { if (empty($file)) { $this->msg("Did not pass file name"); $this->m_filename = "NO FILE GIVEN"; } else { $this->m_filename = $file; } } function msg($mesg,$line=0) { fputs($this->m_fileLink, date("Y-M-d D G:i "). "Message: ".$mesg.chr(13).chr(10). "File: ".$this->m_filename.chr(13).chr(10). "Line Number: ".$line.chr(13).chr(10).chr(13).chr(10)); echo "<BR>".date("Y-M-d D G:i")." Error Message: $mesg<BR>File Name: ".$this->m_filename." Line Number: $line<BR>"; } function halt($mesg,$error=0,$line=0) { fputs($this->m_fileLink, date("Y-M-d D G:i"). "Message: ".$mesg.chr(13).chr(10). "File: ".$this->m_filename.chr(13).chr(10). "Line Number: ".$line.chr(13).chr(10).chr(13).chr(10)); die("<BR>".date("Y-M-d D G:i")." Error Message: $error - $mesg<BR>File Name: ".$this->m_filename." Line Number: $line<BR>"); } function destroyObject() { if($this->m_fileLink) { fclose($this->m_fileLink); } } } // End Class Declaration ?>