controller.php 588 B

123456789101112131415161718192021222324
  1. <?php
  2. require_once __DIR__."/../../redis/function.php";
  3. Class Controller{
  4. protected $redis;
  5. protected $response;
  6. function __construct($redis=true) {
  7. if($redis){
  8. $this->redis = redis_connect();
  9. }
  10. $response = ["ok"=>true,"message"=>"","data"=>null];
  11. }
  12. public function error($message){
  13. $this->response = ["ok"=>false,"message"=>$message,"data"=>null];
  14. echo json_encode($this->response, JSON_UNESCAPED_UNICODE);
  15. }
  16. public function ok($data){
  17. $this->response = ["ok"=>true,"message"=>"","data"=>$data];
  18. echo json_encode($this->response, JSON_UNESCAPED_UNICODE);
  19. }
  20. }