<?php
namespace app\index\controller;
/*
*URl访问
*/
class Demo1
{
public function getName($name="peter")
{
return $name;
}
//依赖注入
public function getMethod(\app\common\Temp $temp)
{
$temp->setName("wom");
return $temp->getName();
}
public function bindClass()
{
\think\Container::set('temp','\app\common\Temp');
$temp=\think\Container::get('temp',['name'=>'nishiwo']);
return $temp->getName();
}
public function bindClosure()
{
\think\Container::set('demo',function($domain){
return $domain;
});
return \think\Container::get('demo',['domain'=>'nishi']);
}
}
php知识网