本文整理汇总了PHP中Alert::hasErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Alert::hasErrors方法的具体用法?PHP Alert::hasErrors怎么用?PHP Alert::hasErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alert
的用法示例。
在下文中一共展示了Alert::hasErrors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pass
public static function pass($key = "")
{
return Alert::hasErrors($key) ? false : true;
}
示例2: validate
public function validate()
{
// Check if the uploaded file is actually an image
if (!in_array($this->mimeType, $this->allowedMimes)) {
Alert::error("Image Type", "You may not upload that type of image.", 8);
}
// Check the file size of the image
if ($this->filesize <= 0 or $this->filesize > $this->maxFileSize) {
Alert::error("Image File Size", "The file size must be smaller than " . $this->maxFileSize . " bytes.", 3);
}
// Check the minimum and maximum width of the image
if ($this->minWidth == $this->maxWidth and $this->width != $this->minWidth) {
Alert::error("Image Width", "The image must be " . $this->minWidth . " pixels in width.");
} else {
if ($this->width < $this->minWidth) {
Alert::error("Image Width", "The image must be " . $this->minWidth . " pixels or greater in width.");
} else {
if ($this->width > $this->maxWidth) {
Alert::error("Image Width", "The image must be " . $this->maxWidth . " pixels or less in width.");
}
}
}
// Check the minimum and maximum height of the image
if ($this->minHeight == $this->maxHeight and $this->height != $this->minHeight) {
Alert::error("Image Height", "The image must be " . $this->minHeight . " pixels in height.");
} else {
if ($this->height < $this->minHeight) {
Alert::error("Image Height", "The image must be " . $this->minHeight . " pixels or greater in height.");
} else {
if ($this->height > $this->maxHeight) {
Alert::error("Image Height", "The image must be " . $this->maxHeight . " pixels or less in height.");
}
}
}
// Set invalid if there are any errors
if (Alert::hasErrors()) {
$this->valid = false;
return false;
}
return true;
}
示例3: htmlspecialchars
if (empty($_POST['location'])) {
$alertClass->addAlert('Kuitin sijainti oli tyhjä', 'error');
}
if (empty($_POST['date'])) {
$alertClass->addAlert('Kuitin päivämäärä oli tyhjä', 'error');
}
if (empty($_POST['sum'])) {
$alertClass->addAlert('Kuitin summa oli tyhjä', 'error');
}
if (!is_numeric($_POST['id'])) {
$alertClass->addAlert('Virheellinen kuitin tunnus', 'error');
}
if (!is_float($_POST['sum'])) {
$alertClass->addAlert('Virheellinen kuitin summa', 'error');
}
if ($alertClass->hasErrors()) {
$alertClass->redirect('/list_receipts.php');
}
$receipt = $receiptClass->getReceipt($_POST['id']);
if ($receipt == null) {
$alertClass->addAlert('Kuittia ei löytynyt', 'error');
$alertClass->redirect('/list_receipts.php');
}
if ($receipt['userID'] !== $user['id']) {
$alertClass->addAlert('Sinulla ei ole oikeuksia tähän kuittiin', 'error');
$alertClass->redirect('/list_receipts.php');
}
$receipt->updateReceipt($_POST['id'], htmlspecialchars($_POST['location']), htmlspecialchars($_POST['date']), $_POST['sum']);
$alertClass->addAlert('Kuitin päivittäminen onnistui!', 'success');
$alertClass->redirect("/view_receipt.php?id={$_POST['id']}");
}