據我瞭解,到目前爲止,使用./
引用當前文件夾,而../
引用當前文件夾上一級,並使用/
引用根目錄。 因此,在所有三種情況下在圖像源屬性內添加相對路徑時,它都可以正常工作,但當嘗試使用Include
三種方式時,./
和/
都會引用當前文件夾。 有沒有誤解?因爲我很困惑。我的代碼使用:使用相對路徑時的不同行爲
<?php
echo '<strong>This is the child using ./ </strong><br><br><img src="./image.jpg"><br><br>';
echo '<strong>This is the parent using ../ </strong><br><br><img src="../image.png"><br><br>';
echo '<strong>This is the root using/<br><br><img src="/image.png"></strong><br>';
include('./file.php');
include('../file.php');
include('/file.php');
>
This StackOverflow [answer](http://stackoverflow.com/a/7378824/371392)可能會給你一些清晰的這個話題。 –
您可能對包含路徑有限制,因此根目錄/實際上不是根目錄。 – Progrock
但我可以參考根,如果我不使用包括 –