dongyou6768 2016-11-17 19:35
浏览 8

PHP - 两个目录似乎不起作用

I have a problem concerning direcotries. I need to include a file in my php script, and that file is in another folder than my script. By itself, that isn't a problem, I just go a directory up using ../ and work my way to the file. Then the problem is occuring when my script is two folders deep and I use ../../ and I will get an error. Here is my relevant code:

<?php $rootdir = "../../"; ?>

Which is followed later by:

<?php
    include($rootdir . "style/header.inc.php");

    include($rootdir . "style/navigation.inc.php");
?>

and the file itself is located in root\projects\TWPWeb\ and the file I am trying to include is located in root\style\

Strange thing is that my .css file is located in the exact same folder and gets accessed in the exact same way and does work, while include doesn't.

<link rel="stylesheet" type="text/css" href="<?php echo $rootdir ?>style/style.css">

Any help will be appreciated.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 公交车和无人机协同运输
    • ¥15 stm32代码移植没反应
    • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
    • ¥100 连续两帧图像高速减法
    • ¥15 组策略中的计算机配置策略无法下发
    • ¥15 如何绘制动力学系统的相图
    • ¥15 对接wps接口实现获取元数据
    • ¥20 给自己本科IT专业毕业的妹m找个实习工作
    • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
    • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)