php how to go one level up on dirname(__FILE__)

后端 未结 9 2060
暗喜
暗喜 2020-11-30 21:52

I have a folder structure as follows:

mydomain.com
  ->Folder-A
  ->Folder-B

I have a string from Database that is \'../Folder-B/imag

9条回答
  •  长情又很酷
    2020-11-30 22:29

    One level up, I have used:

    str_replace(basename(__DIR__) . '/' . basename(__FILE__), '', realpath(__FILE__)) . '/required.php';
    

    or for php < 5.3:

    str_replace(basename(dirname(__FILE__)) . '/' . basename(__FILE__), '', realpath(__FILE__)) . '/required.php';
    

提交回复
热议问题