0
HY,我在类中的两个功能,但我想通过这个代码这两个功能调用在相同的URL调用类的特殊机能的研究通过URL在PHP
class RedeemAPI {
private $db;
// Constructor - open DB connection
function __construct() {
$this->db = new mysqli('localhost', 'root', '', 'promos');
$this->db->autocommit(FALSE);
}
// Destructor - close DB connection
function __destruct() {
$this->db->close();
}
// Main method to redeem a code
function redeem() {
echo 'someone is here before';
}
function users() {
$array = array();
$array[0]= "user 1";
$array[1]= "user 2";
$array[2]= "user 3";
sendResponse(200, json_encode($array), 'application/json');
return true;
}
}
$api = new RedeemAPI;
$api->redeem();
$api->users();
击中函数名称来调用类的特定功能一次我打URL测试/ apicall.php /用户/