當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WebRequest::postFloat方法代碼示例

本文整理匯總了PHP中WebRequest::postFloat方法的典型用法代碼示例。如果您正苦於以下問題:PHP WebRequest::postFloat方法的具體用法?PHP WebRequest::postFloat怎麽用?PHP WebRequest::postFloat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WebRequest的用法示例。


在下文中一共展示了WebRequest::postFloat方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: showEditRoomPage

 private function showEditRoomPage()
 {
     if (WebRequest::wasPosted()) {
         try {
             // get variables
             $rname = WebRequest::post("rname");
             $rtype = WebRequest::postInt("rtype");
             $rmin = WebRequest::postInt("rmin");
             $rmax = WebRequest::postInt("rmax");
             $rprice = WebRequest::postFloat("rprice");
             $id = WebRequest::getInt("id");
             // data validation
             if ($rname == "") {
                 throw new CreateRoomException("blank-roomname");
             }
             if ($rtype == 0) {
                 throw new CreateRoomException("blank-roomtype");
             }
             if ($rmax < 1 || $rmin < 0) {
                 throw new CreateRoomException("room-capacity-too-small");
             }
             if ($rmin > $rmax) {
                 throw new CreateRoomException("room-capacity-min-gt-max");
             }
             if ($rprice != abs($rprice)) {
                 throw new CreateRoomException("room-price-negative");
             }
             $room = Room::getById($id);
             if ($room == null) {
                 throw new Exception("Room does not exist");
             }
             // set values
             $room->setName($rname);
             $room->setType($rtype);
             $room->setMinPeople($rmin);
             $room->setMaxPeople($rmax);
             $room->setPrice($rprice);
             $room->save();
             global $cScriptPath;
             $this->mHeaders[] = "Location: {$cScriptPath}/Rooms";
         } catch (CreateRoomException $ex) {
             $this->mBasePage = "mgmt/roomEdit.tpl";
             $this->error($ex->getMessage());
         }
     } else {
         $this->mBasePage = "mgmt/roomEdit.tpl";
         $room = Room::getById(WebRequest::getInt("id"));
         if ($room == null) {
             throw new Exception("Room does not exist");
         }
         $this->mSmarty->assign("roomid", $room->getId());
         $this->mSmarty->assign("rname", $room->getName());
         $this->mSmarty->assign("rmin", $room->getMinPeople());
         $this->mSmarty->assign("rmax", $room->getMaxPeople());
         $this->mSmarty->assign("rprice", $room->getPrice());
         $this->mSmarty->assign("rtype", $room->getType()->getId());
     }
     $this->mSmarty->assign("rtlist", RoomType::$data);
 }
開發者ID:vulnerabilityCode,項目名稱:hotel-system,代碼行數:59,代碼來源:MPageRooms.php


注:本文中的WebRequest::postFloat方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。