note 16814 added to functions

From: Date: Wed, 14 Nov 2001 17:47:59 +0000
Subject: note 16814 added to functions
Groups: php.notes 
Request: Send a blank email to php-notes+get-20839@lists.php.net to get a copy of this message
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: 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. -- http://www.php.net/manual/en/functions.php http://master.php.net/manage/user-notes.php?action=edit+16814 http://master.php.net/manage/user-notes.php?action=delete+16814 http://master.php.net/manage/user-notes.php?action=reject+16814

« previous php.notes (#20839) next »