Ask the PHP guru to explain the following code-specific procedures in detail

Source: Internet
Author: User
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 '.
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.