Provides various official and user-released code examples. For code reference, you are welcome to exchange the public part Loading Method on the learning page.
// Public view head-end separation method loaded under common Controller
Public function common_view ($ view_content)
{
Header ("Content-type: text/html; charset = UTF-8 ");
// Instantiate the View class
$ View = new \ think \ View ('', \ think \ Config: get ('view _ replace_str '));
// Obtain the content of the current page and transmit the content to the page
$ View-> content = $ view_content;
// Load the public part view of the page
Return $ view-> fetch ('common/common ');
}
// Page loading method for loading other controllers (all inheriting the common Controller)
Public function index (){
$ View = new \ think \ View ();
// Load the view to obtain the content of the current page
$ View_content = $ view-> fetch ();
Return self: common_view ($ view_content );
}
Add
// Configure system variables
'View _ replace_str '=> [
'/Public' =>'/Public /',
''=> '/',
]
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB