PHP的相对和绝对路径 [英] php relative and absolute paths

查看:93
本文介绍了PHP的相对和绝对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经读到,当包含一个使用绝对路径的php文件比相对路径具有更快的处理时间时.

I have read that when including a php file that using absolute paths has a faster processing time than relative paths.

您建议使用什么?

include("includes/myscript.php");

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

甚至

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

还是我真的不应该担心的事情?

Or is it something that I really shouldn't worry about?

推荐答案

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

I usually set a constant, either manually or like this:

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

然后做

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

这篇关于PHP的相对和绝对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆