考虑到有些功能是复用的,可以将一些复用的功能放到一个服务里面公用!

例如:公共模块新建一个服务类:

Thinkphp---自定义服务类!

示例:

<?php
namespace Common\Service;
// use Think\Controller; // 可以使用 Thinkphp的 Controller
// use Think\Model; // 可以使用 thinkphp的 model 
class Service{
    public function send(){
        echo '这里是发送方法!';
    }
}

具体使用:

Thinkphp---自定义服务类!

 第二种方法:

Thinkphp---自定义服务类!

示例:

<?php
namespace Service;
class Service{
    public function send(){
        echo '这里是发送方法!';
    }
}

具体使用:

Thinkphp---自定义服务类!

 

相关文章:

  • 2021-11-03
  • 2021-07-26
  • 2021-09-08
  • 2021-08-19
  • 2022-12-23
  • 2022-01-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-31
  • 2021-12-01
  • 2021-09-13
  • 2022-01-19
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案