我從笨下面的代碼index.php
__FILE__是什麼意思?
我的理解是,
如果在$system_folder
字符串的位置(在這種情況下CIcore_1_7_1)爲false
, 如果realpath
函數存在和/
(?)是不是false
, $system_folder
被分配給(?)/$system_folder
。 否則$system_folder
被分配給$system_folder
,用/
代替\\
。
Q1。 realpath函數的含義是什麼? Q2302。這是什麼意思?
@realpath(dirname(__FILE__))
Q3。我對嗎?我有任何誤解嗎?
Q4。你需要什麼樣的情況下面?
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);
}
爲什麼有兩個\ s,而不是一個\? – shin 2009-10-02 10:03:04
因爲\是轉義字符 - 在一個字符串中加上一個引號,所以你可以使用「this is \」一個引號「,所以要放一個反斜線,你需要兩個:」這是一個反斜槓「 – Greg 2009-10-02 10:06:02