How exactly do you pass variables to controller actions via url?

This is really odd. I could swear this worked before, but I’m having trouble setting it up now.

I downloaded Yii 1.1.19 and started from scratch. Unzipped, and went straight to

localhost/yii2/demos/blog/index.php/site/contact

It worked, no problems. Then, I went into SiteController.php and modified the actionContact.

From:


public function actionContact() {

...

}

To:


public function actionContact($string) {

echo $string;

...

}

Now, if I go to localhost/yii2/demos/blog/index.php/site/contact/testString, it gives 400 error.

What am I doing wrong? Too used to codeigniter now >_>


localhost/yii2/demos/blog/index.php/site/contact/testString

Needs to be:


localhost/yii2/demos/blog/index.php/site/contact/string/testString

Unless you write your own route rules the variable name needs to precede the variable value.