note 108146 added to functions.user-defined

From: Date: Sun, 01 Apr 2012 23:11:04 +0000
Subject: note 108146 added to functions.user-defined
Groups: php.notes 
Request: Send a blank email to php-notes+get-186936@lists.php.net to get a copy of this message
There isn't anything wrong with that. B() is in the global scope, and is therefore accessible at any point in the script. You may have been thinking of something like example #2, but in that example, foo() was encased within another block, which means it wasn't parsed until it's condition was checked and met. I guess you could think of it as a recursive parser (Although I cannot claim to have any idea of how PHP's parser was coded on the backend). The top-level code (not in any brackets, functions, or other types of blocks) is parsed first. All coorasponding functions are defined, and stored. Next, the script begins to execute. When a conditional, block, or function is met, the block is scanned and any new functions, which need defining, are defined at that time. I know that statement was two years old, but I figured I'd post some sort of explanation in order to clear up any other misguided new users. I hate finding a post with the exact same question, and no answer on the internet. XKCD, Wisdom of the Ancients: http://xkcd.com/979/ ---- Server IP: 69.147.83.197 Probable Submitter: 166.128.62.103 ---- Manual Page -- http://www.php.net/manual/en/functions.user-defined.php Edit -- https://master.php.net/note/edit/108146 Del: integrated -- https://master.php.net/note/delete/108146/integrated Del: useless -- https://master.php.net/note/delete/108146/useless Del: bad code -- https://master.php.net/note/delete/108146/bad+code Del: spam -- https://master.php.net/note/delete/108146/spam Del: non-english -- https://master.php.net/note/delete/108146/non-english Del: in docs -- https://master.php.net/note/delete/108146/in+docs Del: other reasons-- https://master.php.net/note/delete/108146 Reject -- https://master.php.net/note/reject/108146 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#186936) next »