Please explain in detail the following code specific flow of PHP master
File name: index.php (under the root directory)
The code is as follows:
Define (' Is_member ', TRUE);
Define (' Fcpath ', DirName (dirname (__file__)). ' /');
if (Isset ($_get[' s ')) && preg_match ('/^[a-z]+$/i ', $_get[' s ']) && $_get[' s ']! = ' Member ') {
if (Is_dir (fcpath.$_get[' s ')) {
Define (' APPPATH ', fcpath.$_get[' s '). ' /');
Define (' App_dir ', $_get[' s ');
$_get[' d '] = ' member ';
} elseif (Is_dir (fcpath. ' app/'. $_get[' s '). ' /')) {
Define (' APPPATH ', Fcpath. ' app/'. $_get[' s '). ' /');
Define (' App_dir ', $_get[' s ');
$_get[' d '] = ' member ';
}
}
if (!defined (' APPPATH ')) define (' APPPATH ', DirName (__file__). ' /');
Require Fcpath. ' index.php ';
The entire PHP file code is some, there is no context
When the parameter is: Index.php?c=register&m=index, the program starts to display/templates\member\default\register.html content in the root directory
When the parameter is: Index.php?c=login&m=index, the program starts to display/templates\member\default\login.html content in the root directory
When the parameter changes, only the contents of the HTML file are highlighted, the Address bar address is not changed or the Index.php?c=xxxx&m=index is only the parameter changes
I do not understand how a few lines of code is a process, why the content of the HTML file is displayed
Please PHP master detailed explanation of the following code each sentence of the specific process, thank you very much!
------to solve the idea----------------------
is a program that goes to the specified page according to the argument.
There are two judgments, one is to determine whether the necessary parameters have been successfully transmitted, and the second is to determine if the specified directory is in the root directory, or in the app directory;
Finally, according to the results of the decision to jump to the corresponding page.
------to solve the idea----------------------
Do not understand, because this code is not based on $_get[' C ' to make a selective action (that is done in Fcpath. ' index.php ')
This code only selects the items that should be entered according to $_get[' s '
And the two URLs you tested:
Index.php?c=register&m=index
Index.php?c=login&m=index
Does not have an s parameter
------to solve the idea----------------------
Define (' Fcpath ', DirName (dirname (__file__)). ' /');
Parent directory of the current file
$FN = ' templates/member/default/register.html ';
echo dirname ($FN); Templates/member/default
Echo dirname (DirName ($FN)); Templates/member
------to solve the idea----------------------
You printed it out to see if you knew?
echo fcpath. ' index.php ';
------to solve the idea----------------------
The final implementation is
Require BasePath. ' core/codeigniter.php ';
Of course it's in there.
Anyway, you found a place to deal with $_get[' C '.