I am new to Slim Framework and PHP. I cant get this to work, if I use a normal function and use "foo" as a parameter, it works, but doesnt work like this, even tho the documentation uses pretty much the same thing http://docs.slimframework.com/
<?php
    require 'Slim/Slim.php';
    session_start();
    \Slim\Slim::registerAutoloader();
    $app = new \Slim\Slim();
    $foo = function() {
       global $app;
        if(!isset($_SESSION["user_id"])) {
            $app->redirect("/redirecto/login");
        } else {
            echo "Authenticated";
        } 
    }
    $app->get("/", $foo, function() {
        global $app;
        $app->render('index.php');
    });
    $app->get("/login", function() use ($app) {
        $app->render("login.php");
    });
?>
The error is
Parse error: syntax error, unexpected '$app' (T_VARIABLE) in C:\xampp\htdocs\redirecto\index.php on line 41 
(the $app->get("/", $foo, function() { line )