Ho il seguente codice da Codeigniter index.php
Che cosa significa __FILE__?
mia comprensione è che,
Se /
della posizione stringa $system_folder
(in questo caso CIcore_1_7_1) è false
, e se realpath
la funzione esiste e (?) È non false
, $system_folder
è assegnato a (?) /$system_folder
. else $system_folder
viene assegnato a $system_folder
con la sostituzione di \\
con /
.
Q1. Cosa significa funzione realpath?
Q2. Cosa significa questo?
@realpath(dirname(__FILE__))
Q3. Ho ragione? Ho qualche malinteso?
Q4. Che tipo di situazione hai bisogno di quanto segue?
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);
}
Perché ci sono due \ s, invece di uno \? – shin
Poiché \ è il carattere di escape - per inserire una virgoletta all'interno di una stringa si usa "this is \" una citazione ". Quindi per inserire una barra rovesciata sono necessari due di questi:" this is \\ a backslash " – Greg