douanye8442 2016-09-11 17:46
浏览 36

包括来自不同文件夹的文件包括(“./".$_GET['id'].".php”);

hi everybody just found this code

<?PHP
if (isset($_GET['id'])) {
    if (!empty($_GET['id']) && $_GET['id'] != "index") {
        if (file_exists($_GET['id'].".php")) {
            include ("./".$_GET['id'].".php");
        } else {
            echo "Not Found section";
        }
    } else {
        include ("start.php");
    }
} else {
    include ("start.php");
} ?>

<a href="index.php?id=gallery">Gallery</a>

i want use it , but i have my files in another folder: "FILESPHP", how i can make link to FILESPHP folder? .. thankyou.

  • 写回答

2条回答 默认 最新

  • dqdt45183 2016-09-11 17:58
    关注

    Consider using google before.

    • with getcwd() you get your current directory
    • you can navigate from there as in every linux

    Kind of:

    <?PHP
    if (isset($_GET['id'])) {
        if (!empty($_GET['id']) && $_GET['id'] != "index") {
            if (file_exists($_GET['id'].".php")) {
                include ("./FILESPHP/".$_GET['id'].".php");
            } else {
                echo "Not Found section";
            }
        } else {
            include ("FILESPHP/start.php");
        }
    } else {
        include ("FILESPHP/start.php");
    } ?> 
    
    评论

报告相同问题?