yii第二步

yii第二步:

 

main.php

 

 

'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'game/guess/<g:\w>'=>'game/guess',
'gou/games/<g:\w>'=>'gou/game',
//index.php/gou/d(实际地址) => gou/index(真实隐射地址gou/index/g/d)
'gou/<g:\w>'=>'gou/index',
),
),

 

实例:

GouController.php

class GouController extends CController
{
    public function actionIndex(){
        $this->render('index');
    }

    public function actionGame()
    {
        echo $this->createUrl('gou/games/x', array() );
        echo "<hr>";
        var_dump($_GET);
        $this->render('game');
    }
}

 

 

view/gou/index.php

<?php echo CHtml::link('aaaa', array('gou/games/a') ); ?><br>
<?php echo CHtml::link('bbbb', array('gou/games/b') ); ?><br>
<?php echo CHtml::link('cccc', array('gou/games/c') ); ?><br>
<a href="<?php echo $this->createUrl('gou/games/d', array() ); ?>">dddddd</a><br>
<a href="<?php echo $this->createUrl('gou/games/e', array() ); ?>">eeeee</a><br>

实际生成的HTML

<a href="/yii/demos/helloworld/index.php/gou/games/a">aaaa</a><br>
<a href="/yii/demos/helloworld/index.php/gou/games/b">bbbb</a><br>
<a href="/yii/demos/helloworld/index.php/gou/games/c">cccc</a><br>
<a href="/yii/demos/helloworld/index.php/gou/games/d">dddddd</a><br>
<a href="/yii/demos/helloworld/index.php/gou/games/e">eeeee</a><br>

 

posted @ 2014-08-28 22:10  穆晟铭  阅读(252)  评论(0编辑  收藏  举报