__FILE__是什么意思? [英] What does __FILE__ mean?

查看:416
本文介绍了__FILE__是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有来自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); 
}

推荐答案

  1. realpath() 函数为您提供文件系统路径,以及任何符号链接和目录遍历(例如../../)已解决. dirname() 函数仅提供目录,而不包含其中的文件.

  1. The realpath() function gives you the file-system path, with any symbolic links and directory traversing (e.g. ../../) resolved. The dirname() 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屋!

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