thinkphp in view of how to call controller

This problem is really a headache or inadvertently solved (here simply show you how to call)

1. First, define a route to the view controller layer

Route::rule('demo','index/User/add','get');

2. Render method to add the User class in view of the index module in the controller, I need to call it in the view is add1 () method

. 1  class the User {
 2      public  function the Add () {
 . 3       return View ();
 . 4      }
 . 5      public  function ADD1 () {
 . 6          return "Congratulations on your success to call me ' ;
 7      }
 8 }
Render View Controller

3. The call controller code view layer (ADD1 under Method User class index module)

<a href="{:url('index/User/add1')}">点击</a>

 

Guess you like

Origin www.cnblogs.com/yaoliuyang/p/12407714.html