Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Any idea how i can access my previously declared variables from inside an included file in a route ?
- If i "include()" a file where i set some variables, that i need inside the routed files... variables seems to not be declared.
- The idea is i have an old app coded, that i can't modify, and i am using Slim framework to develop an Admin area for it. Everything works fine but that, and i can't touch the old code... ideas ?
- Thanks in advance
- */
- /* SAMPLE CODE: */
- <?
- // BASE
- require 'Slim/Slim.php';
- include("../_config.php"); // Old bloated software with variables declared, for example $VARIABLE=1;
- $app = new Slim(Array(
- 'templates.path' => "./t"
- ));
- $log = $app->getLog();
- // SECTION
- $app->map('/section(/:action)', function ($action = false) use ($app) {
- if ($action) {
- include("mods/section.php"); // Cant access $VARIABLE from section.php, only with a "global $VARIABLE"
- }
- else { do404(); }
- })->via('GET', 'POST');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement