note 77773 deleted from function.create-function by nlopess

From: Date: Wed, 12 Sep 2007 19:12:38 +0000
Subject: note 77773 deleted from function.create-function by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-130431@lists.php.net to get a copy of this message
Note Submitter: msakamoto-sf at users dot sourceforge dot net ---- How about creating pseudo lambda technique like below? ------------------- sample.php ------------------ <?php ob_start(); ?> static $c = 0; $c++; return $a + $b + $c; <?php $_code = ob_get_contents(); ob_end_clean(); $lambda = create_function('$a, $b', $_code); echo $lambda(1, 2)."\n"; echo $lambda(3, 4)."\n"; ?> ------------------------------------------------- It will be: $ php hoge3.php 4 # 1($a) + 2($b) + 1($c++) 9 # 3($a) + 4($b) + 2($c++) In normal usage, special chars escapement (like ', ", \) is messy for me and leads many syntax errors! But above technique, source is more readable and we don't need to pay attention escapement any more. Regards, request for comments.

« previous php.notes (#130431) next »