3

I have watched a youtube tutorial about Laravel. This is the code. I started studying Laravel.

 <?php

class Authors_Controller extends BaseController {

public $restful = true;
public function get_index(){

    $view = View::make('authors.index',array('name'=>'Jedi'))->with('age','18');
    $view->location='somewhere';
    $view['favorite'] = 'bacon';    
    return $view;
 }
}
?>

view code

<?
 php echo $name;
 echo $age;
 echo $location;
 echo $favorite;
?>

Once I ran the localhost, I get an error that states that the variables are undefined.

3
  • The line break in <?php in your view is likely the problem - I don't think the PHP interpreter is reading this at all. Remove the line break. Commented May 23, 2015 at 6:19
  • it made sure it is a php file. Commented May 23, 2015 at 6:25
  • Are all of the variables not defined or just some? Commented May 23, 2015 at 7:35

1 Answer 1

1

Try this..

<?php

class Authors_Controller extends BaseController {

public $restful = true;
public function get_index(){

    $view = View::make('authors.index',array('name'=>'Jedi'))->with('age','18');
    $view->location='somewhere';
    $view['favorite'] = 'bacon';    

   return View::make('foldername/filename')->with('view',$view);
 }
}
?>
Sign up to request clarification or add additional context in comments.

1 Comment

Would you explain, in the body of your answer, what you have changed and why? We tend to discourage code-only answers here, since readers have to work out what has changed, and they still don't know why those changes would be used.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.