Advertisement
MarcosBL

Slim PHP

Feb 8th, 2012
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. /*
  2.  
  3. Any idea how i can access my previously declared variables from inside an included file in a route ?
  4.  
  5. If i "include()" a file where i set some variables, that i need inside the routed files... variables seems to not be declared.
  6.  
  7. 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 ?
  8.  
  9. Thanks in advance
  10.  
  11. */
  12.  
  13. /* SAMPLE CODE: */
  14.  
  15. <?
  16. // BASE
  17.     require 'Slim/Slim.php';
  18.     include("../_config.php"); // Old bloated software with variables declared, for example $VARIABLE=1;
  19.     $app = new Slim(Array(
  20.         'templates.path' => "./t"
  21.     ));
  22.     $log = $app->getLog();
  23.  
  24. // SECTION
  25.     $app->map('/section(/:action)', function ($action = false) use ($app) {
  26.         if ($action) {
  27.             include("mods/section.php"); // Cant access $VARIABLE from section.php, only with a "global $VARIABLE"
  28.         }
  29.         else { do404(); }
  30.     })->via('GET', 'POST');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement