tôi có cấu trúc tập tin sau đây:PHP require() tương đối lỗi đường dẫn
rootDIR dir1 subdir1 file0.php file1.php dir2 file2.php file3.php file4.php
file1.php
đòi hỏi file3 và file4 từ dir2 như thế này:
require('../../dir2/file3.php')
file2.php
đòi hỏi file1.php
như thế này:
require('../dir1/subdir1/file1.php')
NHƯNG sau đó yêu cầu trong tệp1 không mở được tệp3 và file4 (có thể do con đường relativeness)
Tuy nhiên, lý do là gì và những gì tôi có thể làm cho file2.php
nên file1.php
đúng yêu cầu file3 và file4
http://stackoverflow.com/questions/11383960/how-to-refer-back-to-public-html-root-file-using-include-after-going-up-one-file Tại đây bạn tìm thấy giải thích rõ ràng. –