note 12673 deleted from function.create-function by cmb

From: Date: Thu, 07 Jul 2022 14:46:33 +0000
Subject: note 12673 deleted from function.create-function by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218930@lists.php.net to get a copy of this message
Note Submitter: maxim at maxim dot cx ---- for those who want to assign it's own name to a function consider this code: <?php $fname = 'hello'; $func = sprintf(' function %s($v="") { Return "$v<BR>"; } ', $fname ); eval($func); echo $fname('Please print it.... please....'); ?> what it does is, : Creats a function as a string; : Replaces the function name with $fname value; : Converts the string into a REAL php code with eval() : Calls the function using the variable function as declared before ($fname); Simple, isn't it? Can work well as an abstraction layer for portability and/or compatibility purposes Maxim Maletsky maxim@maxim.cx // PHPBeginner.com

« previous php.notes (#218930) next »