Controller class of mvc


Im building a site in mvc. Now i have written this controller class. But i cant capture the get variable inside the class using another variable $action1. But if I use switch($_GET[‘cat’]){} it works. Why isn’t it working this way???
this is the error im getting;

Parse error: syntax error, unexpected T_VARIABLE

And this is the code.

class BaseController{

static $action1 = $_GET[‘cat’];

public static function get_cat(){


case “gui”:
return $rec;

case “wwind”:
return $rec;


Also after using switch($_GET[‘cat’]){} the page ‘category.php’ is not getting included. No errors but the file is not getting included… Please someone help me to solve this.

You should add some init method, to initialize those static properties with dynamic values:

static public function init( $action )
    self::$action = $action


Yes definitely.


Read the paragraph:Example #7 Declaring static variables

You can’t assign a variable to a static variable, only a constant value.

static $a = 1; // works
static $b = 'hello'; // works
static $c = $_GET['bla']; // doesn't work
static $d = $a; // doesn't work