views:

16

answers:

1

I have a settings.php file with parametric variables and a functions.php with well, some functions.

functions.php uses some parameters from settings.php and also, functions.php is required once inside index.php. Well, for some reason, when trying to execute index.php the functions can not read the parameters from settings.php in this method. Does anyone know why and a possible workaround for this?

Thanks!!

+1  A: 

Your problem is probably variable scope.

Any variable used inside a function is by default limited to the local function scope.

However, without more information it's hard to say for certain. You can find a full explanation of variable scope and global vs. local variables in the PHP manual.

Adding a line like the one below will likely resolve the issue.

<?php
global $variable_name_from_settings_dot_php;
?>

After that line, inside the function, you would have access to $variable_name_from_settings_dot_php as it was defined in settings.php.

Jason
A simple solution to a hard to explain issue! THANKS!
Gabriel A. Zorrilla