本文整理匯總了PHP中rest::add方法的典型用法代碼示例。如果您正苦於以下問題:PHP rest::add方法的具體用法?PHP rest::add怎麽用?PHP rest::add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rest
的用法示例。
在下文中一共展示了rest::add方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: array
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
require_once "include/lib/database.php";
require_once "include/lib/rest.php";
$db['master']['mmo'] = array("host" => "localhost", "db" => "mmo", "user" => "root", "pass" => "", "prefix" => "");
$database = new database($db);
$database->set_active("master", "mmo");
$rest = new rest(isset($_REQUEST['format']) ? $_REQUEST['format'] : "xml");
$rest->set_setting("caching", false);
$rest->add("post", "register", function ($x1) use(&$database) {
$array['state'] = 1;
$username = $_REQUEST['username'];
$password = md5($_REQUEST['password']);
$r1 = $database->get_row("SELECT user_id FROM users WHERE user_username = '{$username}'");
if (!$r1) {
$database->query("INSERT IGNORE INTO users SET user_username = '{$username}', user_password = '{$password}'");
} else {
$array['state'] = 0;
}
return $array;
});
$rest->run("get,post", $_GET['virtual_path']);