0

PHP: I have several directories with the same file structure in them:

root/
 | listConfigContent.php
105/
 | config/
 |  | config.php
 | images/
 | js/
106/
 | config/
 |  | config.php
 | images/
 | js/
107/
 ⋮

The config.php files do not use namespaces or classes but contain a couple of variables and constants. What do I have to do to access these variables and constants from the listConfigContent.php? As diskussed here (Can PHP namespaces contain variables?) it is not possible to differentiate them by applied namespaces.

Community
  • 1
  • 1
Robbit
  • 1,537
  • 2
  • 9
  • 10
  • If they redefine constants: you're out of luck. If talking _only_ variables: you can include those files in a function with limited scope, and set some container value to the output of `get_defined_vars();` after some cleanup. – Wrikken Nov 23 '14 at 22:08
  • Thank you very much. Your answer seems to be correct and sufficient. Why don't you answer it as an answer, so I can check this question as done? – Robbit Nov 24 '14 at 16:26

1 Answers1

0

I don't know why, but the answerer didn't use the answer function to answer, so I have to in order to make this Question closable:

"If they redefine constants: you're out of luck. If talking only variables: you can include those files in a function with limited scope, and set some container value to the output of get_defined_vars(); after some cleanup."

Robbit
  • 1,537
  • 2
  • 9
  • 10