Is it a good idea to put shared files outside public_html / root? [closed]

I just figured out that I can place files outside the domain root (outside public_html).

The benefit of placing functions outside the domain root is that I can use the same file on multiple domains. If I update my file in a single location, all my domains get updated.

Like this:

include __DIR__ . '/../../my-hidden-folder/functions.php';

My question is, now that it's possible, is it a good idea to work like this? Or are there reasons why this is not a good approach?

Not that it probably matters but I use PHP, Apache and Cpanel.


In general it is good practice to only store data that needs to be directly accessible by an URL in your web root and everything that is not should be stored outside the web root.

The benefit of placing functions outside the domain root is that I can use the same file on multiple domains.

That is not quite true. The include() function doesn't care if files are inside or outside a web root, or if logically that file-system directory used as the web root for a different site...