dongyoudi1342 2018-02-27 16:22
浏览 77

Php包括Parent / Parent / Parent

So i need to include a config File from 3 Directories above. File Structure: root/template/default/premium/myFile.php I am trying to include: root/include/config.php

My attempts:

if(include('../../../include/config.php') == true){
    echo "Config loaded succesfully<br>";
}else{
    echo "There was a Big Time Error loading the Config!<br>";
}

This one is not working, I keep getting the Big Time Error Message ;)

Next i tried with:

include($_SERVER['DOCUMENT_ROOT'] . '/include/config.php');

Also no Luck with this one if I try to access my defines it´s not working.

After Dormilich suggestion on checking the manual i found a Mistake and changed my Code as followed:

if((include'../../../include/config.php') == true){
        echo "Config loaded succesfully<br>";
    }else{
        echo "There was a Big Time Error loading the Config!<br>";
    }

Still not working

  • 写回答

1条回答 默认 最新

  • doujuncuo9339 2018-02-27 16:40
    关注
    if((include $_SERVER['DOCUMENT_ROOT'] . '/include/config.php') == true)
    {
        echo "Config loaded succesfully<br>";
    }
    else
    {
        echo "There was a Big Time Error loading the Config!<br>";
    }
    

    This did the Trick for me. I think i may just mispelled somewhere. But still thanks for bringing the Attention again to the manual.

    评论

报告相同问题?