I have the following controller:
App::import('Controller', 'Users');
class EmployeesController extends AppController
{
}
Now another StackOverflow question said to do the following:
<?php
//Import controller
App::import('Controller', 'Posts');
class CommentsController extends AppController {
//Instantiation
$Posts = new PostsController;
//Load model, components...
$Posts->constructClasses();
public function index($passArray = array(1,2,3)) {
//Call a method from PostsController with parameter
$Posts->doSomething($passArray);
}
}
?>
However if I try to copy this to my code that my code looks like this:
App::import('Controller', 'Users');
class EmployeesController extends AppController {
public $name = 'Employee';
$Users = new UsersController;
I get a syntax error and if I run it anyway I get a fatal error.
So my question is how do I call a function from another controller?