php中的路徑問題與set_include_path使用介紹_PHP教程

來源:互聯網
上載者:User
first:

php中常用的路徑

當前檔案路徑:D:\phpweb\php_example\include_path.php
複製代碼 代碼如下:
1.dirname(__FILE__); //輸出D:\phpweb\php_example
2.$_SERVER['SCRIPT_FILENAME']; //輸出D:/phpweb/php_example/include_path.php

second:

php中的set_include_path

在php中,include檔案時,當包含路徑不為相對也不為絕對時(如:include("example.php")),會先尋找include_path所設定的目錄,然後再在目前的目錄尋找,這也是為什麼很多資料上提到include("./example.php")比include("example.php")效率高的原因。

方法:

1.ini_set("include_path", "/usr/lib/pear"); //所有版本
2.set_include_path("/usr/lib/pear"); //version>=4.3.0
可以用下面的方法,在原有目錄上添加目錄
複製代碼 代碼如下:
$path = '/usr/lib/pear';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);//設定後的include_path變為類似/usr/lib/function;/usr/lib/pear
?>

http://www.bkjia.com/PHPjc/733053.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/733053.htmlTechArticlefirst: php中常用的路徑 當前檔案路徑:D:\phpweb\php_example\include_path.php 複製代碼 代碼如下: 1.dirname(__FILE__); //輸出D:\phpweb\php_example 2.$_SERVER['SC...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.