note 98939 added to function.create-function

From: Date: Fri, 16 Jul 2010 16:59:32 +0000
Subject: note 98939 added to function.create-function
Groups: php.notes 
Request: Send a blank email to php-notes+get-170915@lists.php.net to get a copy of this message
To avoid memory problems, when creating a dynamic function within loops, register it as a global variable, and check if it has already been set; global $my_func; if (!isset($my_func)) { $my_func = create_function($args, $code); } $my_func(); That way you don't end up creating the same function twice (or a couple of million of times, as it happened to me...) ---- Server IP: 87.54.44.10 Probable Submitter: 212.242.207.13 ---- Manual Page -- http://www.php.net/manual/en/function.create-function.php Edit -- https://master.php.net/note/edit/98939 Del: integrated -- https://master.php.net/note/delete/98939/integrated Del: useless -- https://master.php.net/note/delete/98939/useless Del: bad code -- https://master.php.net/note/delete/98939/bad+code Del: spam -- https://master.php.net/note/delete/98939/spam Del: non-english -- https://master.php.net/note/delete/98939/non-english Del: in docs -- https://master.php.net/note/delete/98939/in+docs Del: other reasons-- https://master.php.net/note/delete/98939 Reject -- https://master.php.net/note/reject/98939 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#170915) next »