本文整理汇总了PHP中Answer::error方法的典型用法代码示例。如果您正苦于以下问题:PHP Answer::error方法的具体用法?PHP Answer::error怎么用?PHP Answer::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Answer
的用法示例。
在下文中一共展示了Answer::error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switch
include_once "inc/class.Answer.php";
include_once "inc/class.Curl.php";
include_once "inc/class.DAO.php";
include_once "inc/class.Images.php";
include_once "inc/class.Model.php";
include_once "inc/class.Photo.php";
include_once "inc/class.PhotosData.php";
include_once "inc/class.User.php";
include_once "inc/class.UsersPhotos.php";
// Actions
if (isset($_GET['action'])) {
switch ($_GET['action']) {
case 'get_users':
$answer = Model::getUsersData();
break;
case 'get_users_photos':
$answer = Model::getUsersPhotos();
break;
case 'get_photos_data':
$answer = Model::getPhotosData();
break;
default:
$data = Answer::error('Action not found');
$answer = $data->encode();
break;
}
} else {
$data = Answer::error('Action not found');
$answer = $data->encode();
}
echo $answer;
示例2: getPhotosData
/**
* Метод возвращает json с данными отдельной фотографии
*
* @return string - json с данными отдельной фотографии
*/
public static function getPhotosData()
{
// Общие данные фотографии
$photosData = DAO::getPhotosData($_GET['media_id']);
// Ошибка
if ($photosData->meta->code == 400) {
$answer = Answer::error($photosData->meta->error_message);
} else {
$comments = DAO::getComments($_GET['media_id']);
$likes = DAO::getLikes($_GET['media_id']);
$photo = new PhotosData($photosData->data, $comments->data, $likes->data);
$answer = Answer::good($photo);
}
return $answer->encode();
}