我有班级成绩
class Scores extends Front_Controller
{
public function __construct()
{
parent::__construct();
}
}
和方法记分卡
public function scorecard()
{
$this->load->view('/Cricket/'.$arpf);
}
$ arpf在哪里
array(19) {
[19]=> string(12) "IND_NZ_NOV01"
[20]=> string(18) "ZIM_WI_OCT29_NOV02"
[21]=> string(14) "PAKW_NZW_NOV02"
......
.......
.....
.....
[25]=> string(18) "CAN_NK_OCT30_NOV02"
[26]=> string(19) "WEL_OTG_OCT30_NOV02"
[27]=> ....
.....
....
...
string(18) "CD_AKL_OCT30_NOV02"
}
我想从包含所有个人页面的cricket文件夹加载多个文件来加载
Folder structure
application
views
---Cricket
----IND_NZ_NOV01.php
------ZIM_WI_OCT29_NOV02.php
----PAKW_NZW_NOV02.php
..
..
-----CAN_NK_OCT30_NOV02.php
----WEL_OTG_OCT30_NOV02.php
我想通过
加载页面site_base_url/scores/scorecard/IND_NZ_NOV01.php
site_base_url/scores/scorecard/ZIM_WI_OCT29_NOV02.php
site_base_url/scores/scorecard/PAKW_NZW_NOV02.php
所有网页都有不同的网址。
所以我想从cricket文件夹中加载每个文件,文件名存储在数组$ arpf中如何传递方法记分卡中的所有文件名来加载cricket文件夹中每个文件名的视图,并且可以通过转到单个URL来访问
site_base_url/score/scorecard/pagename
答案 0 :(得分:0)
您可以使用CI的默认路由。
https://www.codeigniter.com/userguide3/general/controllers.html#passing-uri-segments-to-your-methods
public function scorecard($game)
{
$this->load->view('/Cricket/'.$game);
}
www.example.com/scores/scorecard/IND_NZ_NOV01
$game
等于'IND_NZ_NOV01'
,视图会加载文件Cricket/IND_NZ_NOV01.php
。