使用名称 API 创建新控制器

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Api extends CI_Controller {
  //default value
  private $login_credential;

  function __construct() {
    parent::__construct();
    //for user authentication
    $this->load->library('session');

    //set page header type Json as default
    $this->output->set_content_type('application/json');
    //default credentials for user login
    $this->login_credential = array(
        'username'=>'admin',
        'password'=>'test@123',
        'email'=> 'domain@test.com'
      );
  }
}
?>