PHP 包括不同的目录
PHP include different directory
我有一个具有以下结构的网站:
- /根目录/
- 产品/
- products.php
CSS/
- style.css
index.php
所以这是问题所在:index.php 将 style.css 与相对路径链接起来,例如“../CSS/style.css”
和 products.php 包括 index.php 使用 include "../index.php"
但是 css 没有被包括在内,因为现在 index.php 与 products.php 在同一个文件夹中,所以相对路径将不起作用!
有没有绝对路径的解决方案,因为我不想让人们知道我项目的结构
如果没有,你能给我绝对路径吗?或者我能不能以某种方式向用户隐藏绝对路径
提前感谢您的宝贵时间
尝试使用这种语法:
<link rel="stylesheet" type="text/css" href="/CSS/style.css">
我有一个具有以下结构的网站:
- /根目录/
- 产品/
- products.php
- products.php
- 产品/
CSS/
- style.css
index.php
所以这是问题所在:index.php 将 style.css 与相对路径链接起来,例如“../CSS/style.css”
和 products.php 包括 index.php 使用 include "../index.php"
但是 css 没有被包括在内,因为现在 index.php 与 products.php 在同一个文件夹中,所以相对路径将不起作用!
有没有绝对路径的解决方案,因为我不想让人们知道我项目的结构
如果没有,你能给我绝对路径吗?或者我能不能以某种方式向用户隐藏绝对路径
提前感谢您的宝贵时间
尝试使用这种语法:
<link rel="stylesheet" type="text/css" href="/CSS/style.css">