Blogger Information
Blog 64
fans 2
comment 1
visits 46340
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
控制器、请求对象、依赖注入——2018年5月22日
Y的博客
Original
599 people have browsed it

控制器:控制器就是一个类,用来接收用户的请求并将处理结果返回给调用者。

请求对象:就是一个url地址。在请求对象中提供中大最的方法来获取和设置这些URL中的参数。

依赖注入:

实例

<?php 
//依赖注入
class Pencil
{
	public function write()
	{
		return '写字';
	}
}

class Pen 
{
	public function work(Pencil $pencil)
	{
		return '我的铅笔是用来'.$pencil->write();
	}
}

$pencil = new Pencil;
$pen = new Pen;
echo $pen->work($pencil);

运行实例 »

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


Correction status:Uncorrected

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!