How to pass a value to an action.

Hello. How do I pass a parameter to an action? I have something like this:

public function actionLevel($level)


    $this->level = $level;

    ... do stuff ...


What can I put in the URL to pass a value to the “level” action? I was thinking of something like …/index.php?r=game/level&level=4 but that doesn’t work. I tried reading the level through $_GET[‘level’] but that wasn’t it either.


I don't think Yii can do that (passing get params through arguments).  I think $_GET['level'] should contain the value.

$_GET['level'] doesn't contain the value.

What is the standard way to give a value to an action? There has to be a solution, even if it's not exactly the way I imagine it. This need is too elementary for there not to be a way to do it. Imagine that you have a game and on the front page the user chooses what level they want to play at. User clicks on "Level 5". What do you do then? How do you tell Yii that this user wants to play at level 5?

Use $_GET['level']. It should work because this is supported by PHP, not Yii.

It works. I don't understand why it didn't work before… Oh well.

Still APC problem? ;)