The first section describes the thinkphp basic path problem, and the second section describes common uses of thinkphp (M-Layer and V-layer)
We'll start with a new IndexController.class.php on the controller layer (the new file is formatted as xxxController.class.php, with the proposed capitalization), and the framework will not recognize the controller file
Create a new index function
<? PHP namespace Home\controller; use Think\controller; class Indexcontroller extends Controller { public function index () { $this ->assign (' variable ', "Output variable to template"); // assign is to output the controller's variables to the V-level $this ->display (); // assign to output to the template }
Then we add an index folder in the View folder (the name should be the same as the controller name, such as the Aaacontroller controller will create a new AAA folder), Create a new index.html file in index (this name matches the function name of display in the index controller) and enter the following code:
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Document</title></Head><Body>{$variable}</Body></HTML>
{$XXX} This outputs the assign variable in the controller, so we http://localhost/your folder name/index.php?m=home&c=index&a=index in the URL input, The words "Output variable to template" will appear so that the output variable is implemented in the template. This is very common!!
And then the second common place is the U function, I don't say much here. See API documentation
Without the display function is not rendered to the template, can be used to manipulate the logic, and then if the AJAX request an address, the request address is a controller function (reflected in the URL of the A parameter), the other operation is similar to the pure native PHP programming.
thinkphp Basic Primer (2)