scope - PHP - How to be able to use variables inside __autoload() function -
The autoload function I am using is as follows: -
function __autoload ($ moduleName) {// logic file logic to see the existence - if it exists then redirect to the fallback page;)
Does it not take any other logic? I want to make some arguments based on some variables inside the autoload function. How can I do this without the use of global variables?
Thanks
Additional Details
I think this is not possible.
$ viewClassMap = array ('search_classes -: __autoload () class, but still trying to explain with an example I have a modules.config file An array is' = & gt; General class listings, 'search_pack' => 'general pack listing',);
The above array means that the common class list of the class must be included in the search_ squared sequence, in case of search-pack view, class general pack launcher must be included. By default, the commonDisplay class will be included for all other views,
function __autoload ($ VIEWNAME, $ viewClassMap) {if (in_array ($ VIEWNAME, $ viewClassMap)) {$ viewTobeIncluded = $ ViewClassMap [$ VIEWNAME]; Path / in / $ viewTobeIncluded is included; } And (include in path / in / normal display; Now, I think that the logic inside the __autoLoad function is to be moved, and should be calculated to see the first load and then only to be asked to auto-load It also has the purpose of auto loading (whose object was launched to include the class file). Update My Autolon Function not Inside Visual Class Whose object I'm going to start at run time (unlike Blizz's example). I have a common alloload function that is defined in the pagelloader.fp file which is included in the normal francocoller. For each module, view Class is intitated like
$ view = new search_classes ();
Then the common autoload function is to check this parent scene class (this case In commonClassListings), present or not, this For this, the search_classes can see any other and iniate the object, leave the field. For this, I have to pass the $ viewClassMap
array for the autoload function. Is this possible?
The only way I can think of is entering an object object as autoload handler spl_autoload_register ). You can register an instance at any time by specifying the array as callback ($ oInstance, "functionName").
You will be able to set the variable on that square instance before you load the operation that will be triggered.
Edit: A small example on how it works according to your request. Note that I usually work in a class for autoload, so I do not know that it works with an example, but I checked the document and needed it. You can just freeze the function and the array. If it does not work, then 'commonClassListings', 'search_packs' = 'public_view_classMap = array (public searchclasses =' gt; & Gt; Common Packlists',); Public function autoload ($ viewName) {if (in_array ($ viewName, $ this-> seeclascape)) ...}} $ test = new test; Spl_autoload_register (array ($ test, 'autoload'));
Comments
Post a Comment