Self-write Controller:
MainController.class.php:
<?phpnamespace Home\controller; UseThink\controller;classMaincontrollerextendscontroller{//front-mounted Operation Public function_before_xianshi () {Echo"Before display"; } Public functionXianshi () {
echo $_post["name"]; Echo"Main Page";
Pass parameters
echo $name. $age; //Read Configuration /*$model = C (' Url_model '); Echo $model; */ //Dynamic Configuration /*C (' Url_model ', 0); Echo U ("Xianshi");*/ } //Post-Operation Public function_after_xianshi () {Echo"After display"; } Public functionCeshi () {
Registering variables
$this->assign ("text", "Hello");
Call Template display//$this-Display ();
Var_dump (Get_defined_constants (True));//Constant Information}
Public Function Login ()
{
Implement two logic, display, login
if (empty ($_post))
{
$this->display ();
}
Else
{
Implement Login
echo "Implement login";
}
}}
Enter HTTP://LOCALHOST:8080/THIMK/INDEX.PHP/HOME/MAIN/XIANSHI/NAME/LI/AGE/22 in the browser to run the display
To run Ceshi (), also create a folder in view Main, create a ceshi.html document in the new folder
Ceshi.html:
<Head><MetaCharSet= "Utf-8" /><title>Untitled Document</title></Head><Body><ahref= "/THIMK/INDEX.PHP/HOME/MAIN/XIANSHI/NAME/LI/AGE/22">Invoke display operation</a>
<div><{$text}></div>
<form action= "__controller__/xianshi "method=" POST ">
<input type= "text" name= "name"/>
<input type= "Submit" value= "Submission"/>
</form>
</Body>
Enter Http://localhost:8080/thimk/index.php/Home/Main/CeShi in the browser to run the display
Login.html:
<Head><MetaCharSet= "Utf-8" /></Head><Body><formAction= "__action__"Method= "POST"><inputtype= "text"name= "UID" /><inputtype= "Password"name= "pwd" /><inputtype= "Submit"value= "Submit" /></form></Body>
June 13 Controller