首页 > 代码库 > yii第二步
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="http://www.mamicode.com/<?php echo $this->createUrl(‘gou/games/d‘, array() ); ?>">dddddd</a><br><a href="http://www.mamicode.com/<?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>
yii第二步
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。