note 94003 added to language.oop5.decon

From: Date: Sun, 11 Oct 2009 11:13:51 +0000
Subject: note 94003 added to language.oop5.decon
Groups: php.notes 
Request: Send a blank email to php-notes+get-161637@lists.php.net to get a copy of this message
For those who still ***have*** to deal with php4 (like myself, which sucks), contact at tcknetwork dot com noted below that you can have both __constructor and function [classname] in the script, as __constructor has priority. However, to further improve compatability, do a version check in function [classname], as I do in my classes as follows: <?php class Foo{ function __construct($arg){ echo $arg; } function Foo($arg){ if(version_compare(PHP_VERSION,"5.0.0","<")){ $this->__construct($arg); register_shutdown_function(array($this,"__destruct")); } } function __destruct(){ echo "Ack! I'm being destroyed!"; } } ?> This makes it much easier to use your script with fewer compatibility issues. ---- Server IP: 64.71.164.2 Probable Submitter: 173.28.250.86 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.decon.php Edit -- https://master.php.net/note/edit/94003 Del: integrated -- https://master.php.net/note/delete/94003/integrated Del: useless -- https://master.php.net/note/delete/94003/useless Del: bad code -- https://master.php.net/note/delete/94003/bad+code Del: spam -- https://master.php.net/note/delete/94003/spam Del: non-english -- https://master.php.net/note/delete/94003/non-english Del: in docs -- https://master.php.net/note/delete/94003/in+docs Del: other reasons-- https://master.php.net/note/delete/94003 Reject -- https://master.php.net/note/reject/94003 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#161637) next »