Nathanael Nathanael - 19 days ago 5
PHP Question

PHP - Include files without inhereting variables?

Is it possible to include (or, for my uses, run) another PHP file from within a PHP script without inheriting the variables set in the parent script? I know this is mostly possible to do by wrapping the include in a function, but that feels sloppy.

Is there a more elegant alternative?

Answer

Unfortunately, at the time of this writing, it appears that wrapping what you want to include in a function or method is the only way to achieve this.

Comments