note 89861 deleted from function.function-exists by danbrown

From: Date: Thu, 26 Mar 2009 13:15:59 +0000
Subject: note 89861 deleted from function.function-exists by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152470@lists.php.net to get a copy of this message
Note Submitter: Hayley Watson ---- Regarding neelam_ab2003 at yahoo dot co dot in's comment about nested functions. Nested functions _do_ exist once the functions that contain them have been called and the code that defines them is evaluated; until then, they don't. <?php function A(){} function B(){ function C(){ function D(){} } } IsFunctionExist('A'); IsFunctionExist('B'); IsFunctionExist('C'); IsFunctionExist('D'); B(); echo '<br>'; IsFunctionExist('A'); IsFunctionExist('B'); IsFunctionExist('C'); IsFunctionExist('D'); C(); echo '<br>'; IsFunctionExist('A'); IsFunctionExist('B'); IsFunctionExist('C'); IsFunctionExist('D'); function IsFunctionExist($funcName){ echo function_exists($funcName)?" $funcName exists <br>":" $funcName doesn't exist <br>"; } /*O U T P U T A exists B exists C doesn't exist D doesn't exist A exists B exists C exists D doesn't exist A exists B exists C exists D exists */ ?> This makes sense for other functions that are defined at runtime. <?php if(true) { function A(){} } else { function B(){} } IsFunctionExist('A'); IsFunctionExist('B'); /* A exists B doesn't exist */ ?>

« previous php.notes (#152470) next »