note 87556 added to function.include

From: Date: Wed, 10 Dec 2008 13:47:36 +0000
Subject: note 87556 added to function.include
Groups: php.notes 
Request: Send a blank email to php-notes+get-147986@lists.php.net to get a copy of this message
If you wish to abstract away include calls inside functions, or programmatically juggle files to include using functions, just remember: 1. Declare any variables as global if you want those variables "included" in the global scope (ie. if they are used outside the file). 2. Functions are naturally global, so files that only contain functions (libs, sets of api's what have you) can be included anywhere. eg. function nav($i){ include "nav$i.php"; } nav(1); // same as... include "nav1.php"; // ...as long as variables are global So don't feel you can only include/require at the beginning of files, or outside/before functions. You can totally program any sophisticated include behavior. ---- Server IP: 209.41.74.194 Probable Submitter: 76.91.162.70 ---- Manual Page -- http://www.php.net/manual/en/function.include.php Edit -- https://master.php.net/note/edit/87556 Del: integrated -- https://master.php.net/note/delete/87556/integrated Del: useless -- https://master.php.net/note/delete/87556/useless Del: bad code -- https://master.php.net/note/delete/87556/bad+code Del: spam -- https://master.php.net/note/delete/87556/spam Del: non-english -- https://master.php.net/note/delete/87556/non-english Del: in docs -- https://master.php.net/note/delete/87556/in+docs Del: other reasons-- https://master.php.net/note/delete/87556 Reject -- https://master.php.net/note/reject/87556 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#147986) next »