Php 如何写入这些文件的正确路径?
我在这里有一个PHP文件:Php 如何写入这些文件的正确路径?,php,Php,我在这里有一个PHP文件: /public_html/folder1/folder2/index.php /public_html/folderX/folderY/css1.css 此文件需要位于此处的CSS文件: /public_html/folder1/folder2/index.php /public_html/folderX/folderY/css1.css 访问index.php中CSS文件的正确路径是什么?谢谢。假设public\u html是您的根目录: <lin
/public_html/folder1/folder2/index.php
/public_html/folderX/folderY/css1.css
此文件需要位于此处的CSS文件:
/public_html/folder1/folder2/index.php
/public_html/folderX/folderY/css1.css
访问index.php中CSS文件的正确路径是什么?谢谢。假设
public\u html
是您的根目录:
<link rel="stylesheet" type="text/css" href="/folderX/folderY/css1.css" />
我个人的建议是不要干预相对路径;当你开始移动PHP脚本时,它们只会给你带来麻烦;或者更糟糕的是,当您的代码作为另一个脚本的一部分包含时,您无法知道它在哪里
对于CSS(图像)中的引用也可以这样说;CSS文件中的相对路径并非总是从该文件的位置获取,而内联CSS使用页面的位置。您可以将其相对添加到文档中:
。/../folderX/folderY/css1.css
或相对于文档根目录:
/folderX/folderY/css1.css