[wp-trac] [WordPress Trac] #41152: New Function to Require a file
WordPress Trac
noreply at wordpress.org
Sat Jun 24 18:41:58 UTC 2017
#41152: New Function to Require a file
-----------------------------+------------------------------
Reporter: rinkuyadav999 | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Themes | Version:
Severity: normal | Resolution:
Keywords: close | Focuses:
-----------------------------+------------------------------
Comment (by joyously):
Yes, it helps to explain why you should not do what you are suggesting!
>The **include** set of directives generate a //runtime//
`ZEND_INCLUDE_OR_EVAL` operation which calls the Zend compiler to compile
the referenced file. So in general you //**should not**// embed include
statements in a function, as:
>* The include will be executed every time that code path is taken when
the function is called. Compiling the same bit of code 100s of times is a
bad idea.
>* If the code contains elements of global scope (e.g. function or class
declarations) then executing that declaration even twice will cause
compiler errors.
> So don't unless you know what you are doing. Use techniques such are
those described by Albatrosz. Incidentally his `__autoload()` function is
just the sort of example of an exception where this is valid to do.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41152#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list