requiring files in plugin

If I require a file inside a function, does php still have to parse and compile that file even if the function isn’t called?

What I’m trying to do - I have a function that only executes if a certain wordpress option is set.

I’m just wondering if putting the include file inside that function would prevent the include file from even needing to be parsed if the option is turned off.

Thanks.

Yes, PHP will still have to parse and compile the file even if the function isn’t called. The include file will be parsed and compiled when the script is loaded, regardless of whether the function is called or not.

Sponsor our Newsletter | Privacy Policy | Terms of Service