__FILE__是什么意思? [英] What does __FILE__ mean?
问题描述
我有来自Codeigniter index.php
I have the following code from Codeigniter index.php
我的理解是,
如果$system_folder
中的字符串位置的/
(在本例中为CIcore_1_7_1)为false
,
如果realpath
函数存在且AND(?)不是false
,
$system_folder
被分配给(?)/$system_folder
.
否则,将$system_folder
分配给$system_folder
,而将\\
替换为/
.
If /
of string position in $system_folder
(in this case CIcore_1_7_1) is false
,
and if realpath
function exists AND (?) is not false
,
$system_folder
is assigned to (?) /$system_folder
.
else $system_folder
is assigned to $system_folder
with replacing \\
with /
.
Q1. realpath函数是什么意思?
Q1. What does realpath function means?
Q2.这是什么意思?
Q2. What does this mean?
@realpath(dirname(__FILE__))
Q3.我对吗?我有什么误会吗?
Q3. Am I right? Do I have any misunderstanding?
Q4.您需要哪种情况?
Q4. What kind of situation do you need the following?
str_replace("\\", "/", $system_folder)
$system_folder = "CIcore_1_7_1";
/*
|---------------------------------------------------------------
| SET THE SERVER PATH
|---------------------------------------------------------------
|
| Let's attempt to determine the full-server path to the "system"
| folder in order to reduce the possibility of path problems.
| Note: We only attempt this if the user hasn't specified a
| full server path.
|
*/
if (strpos($system_folder, '/') === FALSE)
{
if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
{
$system_folder = realpath(dirname(__FILE__)).'/'.$system_folder;
}
}
else
{
// Swap directory separators to Unix style for consistency
$system_folder = str_replace("\\", "/", $system_folder);
}
推荐答案
-
realpath()
函数为您提供文件系统路径,以及任何符号链接和目录遍历(例如../../)已解决.dirname()
函数仅提供目录,而不包含其中的文件.
The
realpath()
function gives you the file-system path, with any symbolic links and directory traversing (e.g. ../../) resolved. Thedirname()
function gives you just the directory, not the file within it.
__FILE__
是一个魔术常数会为您提供当前.php文件的文件系统路径(__FILE__
所在的文件,而不是包含在内的文件.
__FILE__
is a magic constant that gives you the filesystem path to the current .php file (the one that __FILE__
is in, not the one it's included by if it's an include.
大约是正确的声音.
这将从Windows样式(\)路径转换为Unix样式(/).
This is to translate from Windows style (\) paths to Unix style (/).
这篇关于__FILE__是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!