我在部署我的網站時遇到問題。我一直在使用WAMP在Windows下構建它,現在我正在部署到Linux。通過絕對路徑在PHP中包含文件的問題
這樣的代碼在Windows上運行:
req.php
echo "This is req<br>";
ini_set("include_path", "/home/clash/public_html/:".get_include_path());
require "/req1.php";
req1.php
echo "This is req1";
但在生產環境中與消息失敗:
Warning: require(/req1.php) [function.require]: failed to open stream: No such file or directory in /home/clash/public_html/req.php on line 5
Fatal error: require() [function.require]: Failed opening required '/req1.php' (include_path='/home/clash/public_html/:.:/usr/lib/php:/usr/local/lib/php') in /home/clash/public_html/req.php on line 5
ini_set中的路徑是服務器文件系統上網站實際位置的路徑。
我不想避免絕對路徑,因爲我使用的庫在某種程度上依賴於它們。
我相信我在這裏錯過了一些非常簡單的東西,但我無法弄清楚什麼。
謝謝!
就像我說的那樣,這是一個我不想留下來的選項,因爲我使用的框架生成這種包含URL。有沒有辦法自動將它們與應用程序路徑相加? – Corvin