当前位置: 首页>>代码示例>>PHP>>正文


PHP Input::getNumber方法代码示例

本文整理汇总了PHP中Input::getNumber方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::getNumber方法的具体用法?PHP Input::getNumber怎么用?PHP Input::getNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Input的用法示例。


在下文中一共展示了Input::getNumber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processForm

function processForm($postImage)
{
    $errors = [];
    $errors['count'] = 0;
    $today = date("Y-m-d");
    //pass this to be inserted into the database
    //form was submitted when $_POST is not empty
    if (!empty($_POST)) {
        try {
            $category = Input::getString('category');
        } catch (Exception $e) {
            $errors['category'] = 'Category: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            $postingTitle = Input::getString('title');
        } catch (Exception $e) {
            $errors['title'] = 'Posting Title: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            $price = Input::getNumber('price');
        } catch (Exception $e) {
            $errors['price'] = 'Price: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            $description = Input::getString('description');
        } catch (Exception $e) {
            $errors['description'] = 'Description: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            $date_posted = Input::getDate('date_posted');
        } catch (Exception $e) {
            $errors['date_posted'] = 'Date Posted: ' . $e->getMessage();
            $errors['count']++;
        }
        if ($errors['count'] == 0) {
            $adObject = new AdModel();
            $adObject->category = $category;
            $adObject->title = $postingTitle;
            $adObject->price = $price;
            $adObject->description = $description;
            var_dump($postImage);
            $adObject->image = $postImage;
            $adObject->date_posted = $today;
            // hardcoded:  $adObject->user_id = $_SESSION['user_id'];
            $adObject->users_id = 1;
            $adObject->save();
            //unset the $_SESSION['image'] - will be using the one in the database
            unset($_SESSION['image']);
            header("Location: /ads.show.php?id=" . $adObject->id);
            //this will be the $_GET for the ads.show.php
            die;
        }
    }
    return $errors;
}
开发者ID:LZJCodeup,项目名称:AdLister,代码行数:59,代码来源:ads.create.php

示例2: getPrice

 public static function getPrice()
 {
     try {
         return Input::getNumber('price');
     } catch (Exception $e) {
         self::addError($e->getMessage());
     }
 }
开发者ID:adlisterproject,项目名称:sketchy-b,代码行数:8,代码来源:ValidateAd.php

示例3: deletepark

function deletepark($dbc)
{
    $deleteid = Input::getNumber('id');
    $deletequery = $dbc->prepare('DELETE FROM national_parks WHERE id = :id');
    $deletequery->bindValue(':id', $deleteid, PDO::PARAM_INT);
    $deletequery->execute();
    header("location: national_parks.php");
    die;
}
开发者ID:Rwilkins1,项目名称:Codeup-Web-Exercises,代码行数:9,代码来源:national_parks.php

示例4: processForm

function processForm($adObject, $postImage)
{
    $errors = [];
    $errors['count'] = 0;
    //form was submitted when $_POST is not empty
    if (!empty($_POST)) {
        try {
            $postingTitle = Input::getString('title');
        } catch (Exception $e) {
            $errors['title'] = 'Posting Title: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            $price = Input::getNumber('price');
        } catch (Exception $e) {
            $errors['price'] = 'Price: ' . $e->getMessage();
            $errors['count']++;
        }
        try {
            $description = Input::getString('description');
        } catch (Exception $e) {
            $errors['description'] = 'Description: ' . $e->getMessage();
            $errors['count']++;
        }
        if ($errors['count'] == 0) {
            //update the database
            // $adObject = new AdModel();
            $adObject->title = $postingTitle;
            $adObject->price = $price;
            $adObject->description = $description;
            $adObject->id = $_GET['id'];
            if ($postImage == "Database Image") {
                //no image was uploaded - use the database image
                $adObject->image = $adObject->image;
            } else {
                //new image uploaded - use new image
                $adObject->image = $postImage;
            }
            var_dump("adObject image: " . $adObject->image . "!");
            $adObject->date_posted = $adObject->date_posted;
            $adObject->category = $adObject->category;
            // hardcoded:  $adObject->user_id = $_SESSION['user_id'];
            $adObject->users_id = $_SESSION['user_id'];
            //this is hardcoded for now
            $adObject->save();
            unset($_SESSION['image']);
            header("Location: /ads.show.php?id=" . $adObject->id);
            //this will be the $_GET for the ads.show.php
            die;
        }
    }
    return $errors;
}
开发者ID:LZJCodeup,项目名称:AdLister,代码行数:53,代码来源:ads.edit.php

示例5: updateData

function updateData($dbc)
{
    $errors = [];
    if (!empty($_POST)) {
        try {
            $userName = Input::getString('username');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $password = Input::getString('pwd');
            $password = password_hash($password, PASSWORD_DEFAULT);
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $firstName = Input::getString('firstname');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $lastName = Input::getString('lastname');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $email = Input::getString('email');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $zipCode = Input::getNumber('zipcode');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        if (Input::notEmpty('username') && Input::notEmpty('pwd') && Input::notEmpty('firstname') && Input::notEmpty('lastname') && Input::notEmpty('email') && Input::notEmpty('zipcode')) {
            // create new instance of user class
            $user = new User();
            $user->first_name = $firstName;
            $user->last_name = $lastName;
            $user->user_name = $userName;
            $user->email = $email;
            $user->zipcode = $zipCode;
            $user->save();
            $_SESSION['logInMessage'] = "Your profile has been updated.!!!";
            header("Location:index.php");
            die;
        }
    }
    return $errors;
}
开发者ID:adlistercodeup,项目名称:RNC-Ad-Lister,代码行数:51,代码来源:users.edit.php

示例6: insertPark

function insertPark($dbc)
{
    $errors = [];
    try {
        $date = Input::getDate('date_established');
        $d = $date->format('Y-m-d');
    } catch (Exception $e) {
        $error = "An error occured: " . $e->getMessage() . PHP_EOL;
        array_push($errors['date_established'], $e->getMessage());
    }
    try {
        $name = Input::getString('name');
    } catch (Exception $e) {
        $error = "An error occured: " . $e->getMessage() . PHP_EOL;
        array_push($errors['name'], $e->getMessage());
    }
    try {
        $location = Input::getString('location');
    } catch (Exception $e) {
        $error = "An error occured: " . $e->getMessage() . PHP_EOL;
        array_push($errors['location'], $e->getMessage());
    }
    try {
        $area_in_acres = Input::getNumber('area_in_acres');
    } catch (Exception $e) {
        $error = "An error occured: " . $e->getMessage() . PHP_EOL;
        array_push($errors['area_in_acres'], $e->getMessage());
    }
    try {
        $description = Input::getString('description');
    } catch (Exception $e) {
        $error = "An error occured: " . $e->getMessage() . PHP_EOL;
        array_push($errors['description'], $e->getMessage());
    }
    if ($error) {
        echo $error;
        print_r($errors);
    } else {
        $insert = "INSERT INTO national_parks (name, location, date_established, area_in_acres, description)\n\tVALUES (:name, :location, :date_established, :area_in_acres, :description)";
        $stmt = $dbc->prepare($insert);
        $stmt->bindValue(':name', $name, PDO::PARAM_STR);
        $stmt->bindValue(':location', $location, PDO::PARAM_STR);
        $stmt->bindValue(':date_established', $d, PDO::PARAM_STR);
        $stmt->bindValue(':area_in_acres', $area_in_acres, PDO::PARAM_STR);
        $stmt->bindValue(':description', $description, PDO::PARAM_STR);
        $stmt->execute();
    }
}
开发者ID:aer3934,项目名称:Codeup-Web-Exercises,代码行数:48,代码来源:national_parks.php

示例7: insertData

function insertData($dbc)
{
    $errors = [];
    if (!empty($_POST)) {
        try {
            $name = Input::getString('name');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $location = Input::getString('location');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $date = Input::getDate('date_established');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $area = Input::getNumber('area_in_acres');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        try {
            $description = Input::getString('description');
        } catch (Exception $e) {
            $errors[] = $e->getMessage();
        }
        if (Input::notEmpty('name') && Input::notEmpty('location')) {
            $userData = 'INSERT INTO national_parks (name, location, date_established, area_in_acres, description)
							VALUES (:name, :location, :date_established, :area_in_acres, :description)';
            $userStmt = $dbc->prepare($userData);
            $userStmt->bindValue(':name', $name, PDO::PARAM_STR);
            $userStmt->bindValue(':location', $location, PDO::PARAM_STR);
            $userStmt->bindValue(':date_established', $date, PDO::PARAM_STR);
            $userStmt->bindValue(':area_in_acres', $area, PDO::PARAM_STR);
            $userStmt->bindValue(':description', $description, PDO::PARAM_STR);
            try {
                $userStmt->execute();
            } catch (Exception $e) {
                $errors[] = $e->getMessage();
                throw new Exception('Error: {$e->getMessage()}');
            }
        }
    }
    return $errors;
}
开发者ID:Reni789,项目名称:Codeup-Web-Exercises,代码行数:48,代码来源:national_parks.php

示例8: insertParks

 function insertParks($dbc)
 {
     // Now calls on the Input class's getString and getDate methods with try catches.
     // Try catch create an array of errors for passing to the user in the HTML.
     $errorArray = [];
     try {
         $name = Input::getString('name', 0, 50);
     } catch (Exception $e) {
         $error = $e->getMessage();
         $errorArray['errName'] = $error;
     }
     try {
         $location = Input::getString('location', 0, 50);
     } catch (Exception $e) {
         $error = $e->getMessage();
         $errorArray['errLoc'] = $error;
     }
     try {
         $date_established = Input::getDate('date_established', '1776-07-04', 'next month');
         $date_established = $date_established->format('Y-m-d');
     } catch (Exception $e) {
         $error = $e->getMessage();
         $errorArray['errDate'] = $error;
     }
     try {
         $area_in_acres = Input::getNumber('area_in_acres', 0, 375000000);
     } catch (Exception $e) {
         $error = $e->getMessage();
         $errorArray['errArea'] = $error;
     }
     try {
         $description = Input::getString('description', 0, 500);
     } catch (Exception $e) {
         $error = $e->getMessage();
         $errorArray['errDes'] = $error;
     }
     // If the $errorArray is not empty, this will return out of the method before binding values and executing below. The $errorArray returns with an array of strings.
     if (!empty($errorArray)) {
         return $errorArray;
     }
     $stmt = $dbc->prepare('INSERT INTO national_parks (name, location, date_established, area_in_acres, description) VALUES (:name, :location, :date_established, :area_in_acres, :description)');
     $stmt->bindValue(':name', $name, PDO::PARAM_STR);
     $stmt->bindValue(':location', $location, PDO::PARAM_STR);
     $stmt->bindValue(':date_established', $date_established, PDO::PARAM_STR);
     $stmt->bindValue(':area_in_acres', $area_in_acres, PDO::PARAM_STR);
     $stmt->bindValue(':description', $description, PDO::PARAM_STR);
     $stmt->execute();
 }
开发者ID:anthony87burns,项目名称:codeup-web-exercises,代码行数:48,代码来源:national_parks.php

示例9: insertPark

function insertPark($dbc)
{
    $errors = [];
    try {
        $username = Input::getString('username');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $password = Input::getString('password');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $email = Input::getString('email');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $first_name = Input::getNumber('first_name');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $last_name = Input::getString('last_name');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $phone = Input::getString('phone_number');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    if (!empty($errors)) {
        return $errors;
    }
    $userInput = $dbc->prepare('INSERT INTO users (username, password, email, first_name, last_name, phone) VALUES (:username, :password, :email, :first_name, :last_name, :phone)');
    $userInput->bindValue(':username', $username, PDO::PARAM_STR);
    $userInput->bindValue(':password', $password, PDO::PARAM_STR);
    $userInput->bindValue(':email', $email, PDO::PARAM_STR);
    $userInput->bindValue(':first_name', ucfirst($first_name), PDO::PARAM_STR);
    $userInput->bindValue(':last_name', ucfirst($last_name), PDO::PARAM_STR);
    $userInput->bindValue(':phone', $phone, PDO::PARAM_STR);
    $userInput->execute();
    return $errors;
}
开发者ID:adlister-project,项目名称:Craigslister,代码行数:46,代码来源:users.create.php

示例10: insertPark

function insertPark($dbc)
{
    $errors = [];
    try {
        $park = Input::has('park') ? Input::getString('park') : null;
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $location = Input::has('location') ? Input::getString('location') : null;
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $date_established = Input::has('date_established') ? Input::getDate('date_established') : null;
        $date_established = $date_established->format('Y-m-d');
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $area_in_acres = Input::has('area_in_acres') ? Input::getNumber('area_in_acres') : null;
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    try {
        $description = Input::has('description') ? Input::getString('description') : null;
    } catch (Exception $e) {
        array_push($errors, $e->getMessage());
    }
    if (!empty($errors)) {
        return $errors;
    }
    $query = "INSERT INTO national_parks (park, location, date_established, area_in_acres, description) VALUES (:park, :location, :date_established, :area_in_acres, :description)";
    $stmt = $dbc->prepare($query);
    $stmt->bindValue(':park', $park, PDO::PARAM_STR);
    $stmt->bindValue(':location', $location, PDO::PARAM_STR);
    $stmt->bindValue(':date_established', $date_established, PDO::PARAM_STR);
    $stmt->bindValue(':area_in_acres', $area_in_acres, PDO::PARAM_STR);
    $stmt->bindValue(':description', $description, PDO::PARAM_STR);
    $stmt->execute();
    return $errors;
}
开发者ID:Craig240z,项目名称:CodeUp-Web-Exercises,代码行数:42,代码来源:national_parks.php

示例11: deletePark

function deletePark($dbc)
{
    $errorsArray = [];
    try {
        $delete_park = Input::getNumber('delete_park');
    } catch (Exception $e) {
        $error = $e->getMessage();
        array_push($errorsArray, $error);
    }
    $query = "DELETE FROM national_parks WHERE id = :delete_park";
    $query = $dbc->prepare($query);
    $query->bindValue(':delete_park', $delete_park, PDO::PARAM_INT);
    $query->execute();
    return $errorsArray;
}
开发者ID:ryanski,项目名称:Codeup-Web-Exercises,代码行数:15,代码来源:national_parks.php

示例12: count

<?php

require_once '../default_pw.php';
require_once '../db_connect.php';
require_once '../Input.php';
// defining global variables
$page = Input::has('page_num') ? Input::getNumber('page_num') : 1;
$limit = Input::has('input') ? Input::getNumber('input') : 4;
$offset = $page * $limit - $limit;
// connecting to the database
$parks = $dbc->prepare('SELECT * FROM national_parks LIMIT :limit OFFSET :offset');
$parks->bindValue(':limit', $limit, PDO::PARAM_INT);
$parks->bindValue(':offset', $offset, PDO::PARAM_INT);
$parks->execute();
$parks = $parks->fetchAll(PDO::FETCH_ASSOC);
$no_of_records = $dbc->query("SELECT count(id) FROM national_parks");
$count = $no_of_records->fetchColumn();
require 'np_inputModal.php';
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>U.S. National Parks</title>
	<link rel="stylesheet" href="/css/natty_park.css">
	<link href='https://fonts.googleapis.com/css?family=Delius+Swash+Caps|Amaranth:400,700italic|Work+Sans:300,500,800' rel='stylesheet' type='text/css'>
</head>
<body>
	<header>
		<div class='header'>
开发者ID:lochhead71,项目名称:codeup.dev,代码行数:31,代码来源:national_parks.php

示例13: catch

$errors = [];
// date_time_set('America/Chicago');
if (!empty($_POST)) {
    //prepare database to run query
    try {
        // Create a person
        $item = Input::getString('item');
    } catch (LengthException $e) {
        // Report any errors
        $errors[] = "Item - " . $e->getMessage();
    } catch (InvalidArgumentException $e) {
        $errors[] = "Item - " . $e->getMessage();
    }
    try {
        // Create a person
        $price = Input::getNumber('price');
    } catch (OutOfRangeException $e) {
        // Report any errors
        $errors[] = "Price - " . $e->getMessage();
    } catch (InvalidArgumentException $e) {
        $errors[] = "Price - " . $e->getMessage();
    }
    try {
        // Create a person
        $description = Input::getString('description');
    } catch (LengthException $e) {
        // Report any errors
        $errors[] = "Description - " . $e->getMessage();
    } catch (InvalidArgumentException $e) {
        $errors[] = "Description - " . $e->getMessage();
    }
开发者ID:What-iGot,项目名称:What-iGot-Ad-Lister,代码行数:31,代码来源:add_ad.php

示例14: catch

 } catch (InvalidArgumentException $e) {
     $errors[] = $e->getMessage();
 } catch (LengthException $e) {
     $errors[] = $e->getMessage();
 }
 try {
     $parkDate = DateRangeException::getDate('date_established');
 } catch (OutOfRangeException $e) {
     $erros = $e->getMessage();
 } catch (DateRangeException $e) {
     $errors = $e->getMessage();
 } catch (DateRangeException $e) {
     $errors = $e->getMessage();
 }
 try {
     $parkAreaAcres = Input::getNumber('area_in_acres');
 } catch (InvalidArgumentException $e) {
     $errors = $e->getMessage();
 } catch (OutOfRangeException $e) {
     $errors = $e->getMessage();
 } catch (DomainException $e) {
     $errors = $e->getMessage();
 } catch (RangeException $e) {
     $errors = $e->getMessage();
 }
 try {
     $parkDescription = Input::getString('description');
 } catch (InvalidArgumentException $e) {
     $errors = $e->getMessage();
 } catch (OutOfRangeException $e) {
     $errors = $e->getMessage();
开发者ID:cjsampson,项目名称:codeup.dev,代码行数:31,代码来源:national_parks.php

示例15: Park

$errors = [];

if(Input::has('name') &&
    Input::has('description') &&
    Input::has('area_in_acres') &&
    Input::has('date_established') &&
    Input::has('location')) {
        $park = new Park();
    try {
        $park->name = Input::getString('name');
    } catch (Exception $e) {
        $errors[] = $e->getMessage();
    }

    try {
        $park->area_in_acres = Input::getNumber('area_in_acres');
    } catch (Exception $e) {
        $errors[] = $e->getMessage();
    }

    try {
        $park->date_established = Input::getDate('date_established');
    } catch (Exception $e) {
        $errors[] = $e->getMessage();
    }

    try {
        $park->description = Input::getString('description');
    } catch (Exception $e) {
        $errors[] = $e->getMessage();
    }
开发者ID:ryanorsinger,项目名称:codeup_web_exercises,代码行数:31,代码来源:national_parks.php


注:本文中的Input::getNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。