note 16814 deleted from language.functions by googleguy

From: Date: Mon, 24 Aug 2015 09:58:38 +0000
Subject: note 16814 deleted from language.functions by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-203424@lists.php.net to get a copy of this message
Note Submitter: xpaz at somm dot com ---- It is possible to define a function from inside another function. The result is that the inner function does not exist until the outer function gets executed. For example, the following code: <?php function a () { function b() { echo "I am b.\n"; } echo "I am a.\n"; } if (function_exists("b")) echo "b is defined.\n"; else echo "b is not defined.\n"; a(); if (function_exists("b")) echo "b is defined.\n"; else echo "b is not defined.\n"; ?> echoes: b is not defined. I am a. b is defined. Classes too can be defined inside functions, and will not exist until the outer function gets executed.

« previous php.notes (#203424) next »