note 73512 modified in language.oop5.overloading by danbrown

From: Date: Fri, 14 Nov 2008 17:14:46 +0000
Subject: note 73512 modified in language.oop5.overloading by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-146542@lists.php.net to get a copy of this message
In reply to james at thunder-removeme-monkey dot net, Unfortunately it seems that there is no way to have completely transparent array properties with 5.2.x. The code you supplied works until working with built-in functions that perform type-checks: <?php // Using the same View class $view = new View(); $view->bar = array(); $view->bar[] = "value"; if (is_array($view->bar)) print "is array!\n"; // Not printed // Warning: in_array(): Wrong datatype for second argument in ... if (in_array("value", $view->bar)) print "found!\n"; // Not printed // Successful if (in_array("value", (array)$view->bar)) print "found!\n"; ?> It also seems that 5.1.x is no longer maintained as it's not listed on the downloads page.. Quite frustrating. :/ --was-- In reply to james at thunder-removeme-monkey dot net, Unfortunately it seems that there is no way to have completely transparent array properties with 5.2.x. The code you supplied works until working with built-in functions that perform type-checks: <? // Using the same View class $view = new View(); $view->bar = array(); $view->bar[] = "value"; if (is_array($view->bar)) print "is array!\n"; // Not printed // Warning: in_array(): Wrong datatype for second argument in ... if (in_array("value", $view->bar)) print "found!\n"; // Not printed // Successful if (in_array("value", (array)$view->bar)) print "found!\n"; ?> It also seems that 5.1.x is no longer maintained as it's not listed on the downloads page.. Quite frustrating. :/ http://php.net/manual/en/language.oop5.overloading.php

« previous php.notes (#146542) next »