php的相对路径和绝对路径

标签 php include-path

我读到过,当包含一个使用绝对路径的 php 文件时,处理时间比相对路径快。

您建议使用什么?

include("includes/myscript.php");

include("/home/ftpuser/public_html/includes/myscript.php");

甚至

set_include_path("/home/ftpuser/public_html/includes");
include("myscript.php");

或者这是我真的不应该担心的事情?

最佳答案

我通常设置一个常量,手动或像这样:

define('ROOT', dirname(__FILE__));

然后做

require ROOT . '/include/file.php';

关于php的相对路径和绝对路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1755216/

相关文章:

c++ - 获取 "Cannot open include file: ' atlbase.h' : No such file or directory"error

zend-framework - Ubuntu、zend framework 和 PHPUnit - 测试说明 : PHPUnit was not found in your include_path, 因此不会创建任何测试操作

php - 如何构建 PHP 内容以用于非安全 (http ://) and secure (https://) areas and across multiple directories?

php - 直接在Laravel View 中将URL中传递的参数作为变量获取?

php - 左连接三个 MySQL 表

php - 如何设置要使用的默认 php.ini,OSX Yosemite

javascript - 在 javascript 中使用 PHP 数组

PHP、MySQL、jQuery、AJAX : json data returns correct response but frontend returns error

php - 关于 PHP include 语句的问题

c - Eclipse C/C++ 在构建时不包含文件