<?php
namespace app\index\controller;
use think\Controller;
use think\Db;
class index extends Controller
{
public function index()
{
$db = new Db();
$this->test($db);
}
public function test(Db $param) //是否是Db类的实例
{
var_dump($param);
}
}
<?php
namespace app\index\controller;
use think\Controller;
use think\Db;
class index extends Controller
{
$db = new Db();
if($db instanceof Db){ //(instanceof)判断是否是Db类的实例
echo 'Yes';
}else{
echo 'No';
}
}