Read configuration
C Method: $model = C (' Url_model ');
Dynamic configuration: Some configuration is needed in some places, where it is written
C Method: C (' Url_model ', 0);
The name of the controller uses the hump-named method (capitalized in the first letter)
Pre-action: What needs to be done before calling this method
Post action: What you need to do after calling this method
Cases:
Pre-action method
Public Function _before_xianshi ()
{
Echo ' I'm before the show <br/> ';
}
Public Function Xianshi ()
{
echo "Main Page display <br/>";
}
Post-operation method
Public Function _after_xianshi ()
{
Echo ' I'm after the show <br/> ';
}
Action parameter Binding
Public Function Xianshi ($name, $ids)
{
Echo $name. IDs. " Main Page display <br/> ";
}
Pass a parameter: path mode
Http://localhost:8080/thinkphp/index.php/home/main/xianshi/name/zhangsan
Pass two parameters:
http://localhost:8080/thinkphp/index.php/home/main/xianshi/name/zhangsan/ids/666
Jump page
<a href= "/thinkphp/index.php/home/main/xianshi/ids/1/name/zhangsan" > Invoke display Operation </a>
Case sensitivity setting, default false means URL is case-sensitive true means case insensitive
' Url_case_insensitive ' = true,
Template engine normal tag start tag
' Tmpl_l_delim ' = ' <{',
Template engine normal tag end tag
' Tmpl_r_delim ' = '}> ',
Display the values added from the controller in the template
Public Function Ceshi ()
{
$this->assign ("test", "Hello");//Register variable
$this->display ();
}
In the ceshi.html page
<div><{$test}></div>
Input variables
Post method:
Public Function Xianshi ()
{
echo $_post["name"];
}
In the ceshi.html page
<form action= "/thinkphp/index.php/home/main/xianshi" method= "POST" >
<input type= "text" name= "name"/>
<input type= "Submit" value= "Submission"/>
</form>
Gets system constant information (displayed in groups if the parameter is true)
Public Function Ceshi ()
{
Var_dump (Get_defined_constants (true));
}
__controller__ automatically gets to the controller
Under which root directory the __root__ is placed
__app__ fetch to the entry file
__module__ Current Module
__self__ Current operation method (including parameters after Operation method)
__action__ Current operation method (excluding parameters after action method)
Multiple logical implementations of the same method
Public Function Login ()
{
Implement two logic, display page, implement login
if (empty ($_post))
{
$this->display ();
}
Else
{
Implement Login
echo "Implement login";
}
}
PHP TP Controller