简体   繁体   中英

Including files from different folders include ("./".$_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.

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");
} ?> 

thank you inetphantom,

when refresh page.. FILESPHP/start.php load very GOOD..

but.. when i call files in FILESPHP.. not works..

the example is: <a href="index.php?id=gallery">Gallery</a> show "Not Found section"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM