这对于CodeIgniter3中的PHP Include是否相同?

时间:2016-06-09 12:12:38

标签: php codeigniter codeigniter-3

请向我解释如何操作:

<?php
    if(!isset($_GET['s'])) {
    $_GET['s'] = ""; }
    if ($_GET['s'] == "") { include("Templates/Tutorial/1.tpl"); }
    if ($_GET['s'] == "1") { include("Templates/Tutorial/1.tpl"); }
    if ($_GET['s'] == "2") { include("Templates/Tutorial/2.tpl"); }
    if ($_GET['s'] == "3") { include("Templates/Tutorial/3.tpl"); }
    if ($_GET['s'] == "4") { include("Templates/Tutorial/4.tpl"); }
    if ($_GET['s'] == "5") { include("Templates/Tutorial/5.tpl"); }
?>

非常感谢!

1 个答案:

答案 0 :(得分:1)

我认为这也有效

<?php
    $inc = 1;
    if(isset($_GET['s']) && $_GET['s'] != ""):
        $inc = (int)$_GET['s'];
    endif;

    include("Templates/Tutorial/$inc.tpl");
?>