Blogger Information
Blog 48
fans 3
comment 1
visits 37303
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
依赖注入的实现原理(构造器与普通方法)——2018年5月22日
JackBlog
Original
649 people have browsed it


构造器方法 实例

<?php
namespace app\index\controller;

use think\Request;

class Index
{
	protected $request;
    
	public function __construct(Request $request)
    {
    	$this->request = $request;
    }
     
    public function index()
    {
        return '您的姓名是:'.$this->request->param('username');
    }
    
}

运行实例 »

点击 "运行实例" 按钮查看在线实例

普通方法 实例

<?php
namespace app\index\controller;
use think\Request;
class Demo
{
	
    public function demo(Request $request)
    {
        return '您的姓名是:'.$request->param('username');
    }
    
}

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!