diff --git a/index.php b/index.php
index 7ff5288..a4c2033 100644
--- a/index.php
+++ b/index.php
@@ -29,6 +29,7 @@ function navi() {
PHP Info
Non english route: german
Non english route: arabic
+ Inject variables to local scope
Arrow function test (please enable this route first)
aTrailingSlashDoesNotMatter
aTrailingSlashDoesNotMatter/
@@ -135,8 +136,21 @@ Route::add('/الرقص-العربي', function() {
echo 'Arabic example. Non english letters should work too
';
});
+// Use variables from global scope
+// You can use for example use() to inject variables to local scope
+// You can use global to register the variable in local scope
+$foo = 'foo';
+$bar = 'bar';
+Route::add('/global/([a-z-0-9-]*)', function($param) use($foo) {
+ global $bar;
+ navi();
+ echo 'The param is '.$param.'
';
+ echo 'Foo is '.$foo.'
';
+ echo 'Bar is '.$bar.'
';
+});
+
// Return example
-// Returned data gets echoed
+// Returned data gets printed
Route::add('/return', function() {
navi();
return 'This text gets returned by the add method';