Last active
December 23, 2015 07:39
-
-
Save aurelkurtula/6602290 to your computer and use it in GitHub Desktop.
laravel:passing_variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::get('/', function() //the point represents a slash. So index page is at views/home/index.blade.php | |
{ | |
$greeting = "From home page "; | |
$thing = "doing my thing"; | |
return View::make('home.index')->with( | |
array( | |
'greeting' => $greeting , | |
'thing' => $thing) | |
); | |
}); | |
Route::get('/array', function() //the point represents a slash. So index page is at views/home/index.blade.php | |
{ | |
$data = array( | |
'greeting' => 'From about page' , | |
'thing' => "doing my thing" | |
); | |
return View::make('home.index', $data); | |
}); | |
Route::get('/view', function() //the point represents a slash. So index page is at views/home/index.blade.php | |
{ | |
$view = View::make('home.index'); | |
$view->greeting = "from views"; | |
$view->thing = "page"; | |
return $view; | |
}) ; | |
/* | |
in the home/index view we add | |
echo $greeting | |
echo $thing | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment