簡體   English   中英

相對或絕對路徑未打開

[英]Relative or Absolute path not opening

我很難理解php中相對路徑的過程。 我正在使用WAMP和在Google等上花費數小時后嘗試過的所有東西來工作本地主機,只是錯誤。 錯誤的范圍從“無法打開流:沒有此類文件或目錄”到堆棧錯誤。 我也嘗試過絕對路徑,但結果仍然相同。 我對如何進行不知所措,因此可以真正使用一些幫助。 我已經附上了我嘗試過的程序清單,任何建議都將受到歡迎。 非常感謝

In the admin header file:

<?php require_once('./Connections/connect.php'); ?>
<?php require_once('../../../Connections/connect.php'); ?>
<?php require_once('C:\wamp\www\domain/Connections/connect.php'); ?>

localhost\domain > root > index.php
                          header.php
                          footer.php
                          Connections\connect.php    

localhost\domain\admin > index.php
                         header.php
                         footer.php
                         form-inc.php

localhost\domain\admin\cp\users > index.php <--Users control panel in which I need to call 

                                               header.php & footer.php from the admin     

                                               directory which is where I am having the 

                                               problem.

PHP 5.3
WAMP

嘗試這樣做以避免歧義dirname(__FILE__)

要么

如果您使用的是PHP 5.3或更高版本,請使用__DIR__ > __DIR__

用法-

require dirname(__FILE__) . '/../../filename.php';

要么 -

require __DIR__ . '/../../../filename.php';

手冊中的更多內容-http: //php.net/manual/zh/language.constants.predefined.php

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM