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


PHP Person::setAge方法代码示例

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


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

示例1: getPeople

 public function getPeople($ids, $fields, $options, $token)
 {
     $first = $options->getStartIndex();
     $max = $options->getCount();
     $this->checkDb();
     $ret = array();
     $filterQuery = '';
     $options->setFilterBy(null);
     //DateOfBirth
     $query = "\n\t\tSELECT * FROM `Profiles` WHERE `ID` IN (" . implode(',', $ids) . ") {$filterQuery} ORDER BY `ID`\n\t";
     /*
     		`ID` AS 'id',
     		`NickName` AS 'first_name',
     		`NickName` AS 'last_name',
     		`DescriptionMe` AS 'about_me',
     		20 AS 'age',
     		`DateOfBirth` AS 'date_of_birth',
     		1 AS 'children',
     		'' AS 'ethnicity',
     		'' AS 'fashion',
     		'' AS 'happiest_when',
     		'' AS 'humor',
     		'' AS 'job_interests' 
     */
     $res = mysqli_query($this->db, $query);
     if ($res) {
         while ($row = @mysqli_fetch_array($res, MYSQLI_ASSOC)) {
             $person_id = $row['ID'];
             $sFirstName = isset($row['FirstName']) ? $row['FirstName'] : $row['NickName'];
             $sLastName = isset($row['LastName']) ? $row['LastName'] : '';
             $name = new Name($sFirstName . ' ' . $sLastName);
             $name->setGivenName($sFirstName);
             $name->setFamilyName($sLastName);
             $person = new Person($person_id, $name);
             $person->setDisplayName($name->getFormatted());
             $sAboutMe = isset($row['DescriptionMe']) ? $row['DescriptionMe'] : '';
             $person->setAboutMe($sAboutMe);
             $sDateOfBirth = isset($row['DateOfBirth']) ? date('Y-m-d', $row['DateOfBirth']) : '';
             $sAge = $sDateOfBirth != '' ? $this->bx_getAge($sDateOfBirth) : '';
             $person->setAge($sAge);
             $sChildren = isset($row['Children']) ? $row['Children'] : '';
             $person->setChildren($sChildren);
             $person->setBirthday($sDateOfBirth);
             $sEthnicity = isset($row['Ethnicity']) ? $row['Ethnicity'] : '';
             $person->setEthnicity($sEthnicity);
             $sFashion = isset($row['Fashion']) ? $row['Fashion'] : '';
             $person->setFashion($sFashion);
             $sHappiestWhen = isset($row['HappiestWhen']) ? $row['HappiestWhen'] : '';
             $person->setHappiestWhen($sHappiestWhen);
             $sHumor = isset($row['Humor']) ? $row['Humor'] : '';
             $person->setHumor($sHumor);
             $sJobInterests = isset($row['JobInterests']) ? $row['JobInterests'] : '';
             $person->setJobInterests($sJobInterests);
             $sLivingArrangement = isset($row['LivingArrangement']) ? $row['LivingArrangement'] : '';
             $person->setLivingArrangement($sLivingArrangement);
             $sLookingFor = isset($row['LookingFor']) ? $row['LookingFor'] : '';
             $person->setLookingFor($sLookingFor);
             $sNickName = isset($row['NickName']) ? $row['NickName'] : '';
             $person->setNickname($sNickName);
             $sPets = isset($row['Pets']) ? $row['Pets'] : '';
             $person->setPets($sPets);
             $sPoliticalViews = isset($row['PoliticalViews']) ? $row['PoliticalViews'] : '';
             $person->setPoliticalViews($sPoliticalViews);
             $sProfileSong = isset($row['ProfileSong']) ? $row['ProfileSong'] : '';
             $person->setProfileSong($sProfileSong);
             $person->setProfileUrl($this->url_prefix . '/profile/' . $person_id);
             //'A' TODO
             $sProfileVideo = isset($row['ProfileVideo']) ? $row['ProfileVideo'] : '';
             $person->setProfileVideo($sProfileVideo);
             $sRelationshipStatus = isset($row['RelationshipStatus']) ? $row['RelationshipStatus'] : '';
             $person->setRelationshipStatus($sRelationshipStatus);
             $sReligion = isset($row['Religion']) ? $row['Religion'] : '';
             $person->setReligion($sReligion);
             $sRomance = isset($row['Romance']) ? $row['Romance'] : '';
             $person->setRomance($sRomance);
             $sScaredOf = isset($row['ScaredOf']) ? $row['ScaredOf'] : '';
             $person->setScaredOf($sScaredOf);
             $sSexualOrientation = isset($row['SexualOrientation']) ? $row['SexualOrientation'] : '';
             $person->setSexualOrientation($sSexualOrientation);
             $person->setStatus($row['UserStatus']);
             $person->setThumbnailUrl(!empty($row['thumbnail_url']) ? $this->url_prefix . $row['thumbnail_url'] : '');
             //'A' TODO
             if (!empty($row['thumbnail_url'])) {
                 // also report thumbnail_url in standard photos field (this is the only photo supported by partuza)
                 $person->setPhotos(array(new Photo($this->url_prefix . $row['thumbnail_url'], 'thumbnail', true)));
             }
             $sUtcOffset = isset($row['TimeZone']) ? $row['TimeZone'] : "-00:00";
             $person->setUtcOffset(sprintf('%+03d:00', $sUtcOffset));
             // force "-00:00" utc-offset format
             if (!empty($row['Drinker'])) {
                 $person->setDrinker($row['Drinker']);
             }
             if (!empty($row['Sex'])) {
                 $person->setGender(strtolower($row['Sex']));
             }
             if (!empty($row['Smoker'])) {
                 $person->setSmoker($row['Smoker']);
             }
             /* the following fields require additional queries so are only executed if requested */
             if (isset($fields['activities']) || in_array('@all', $fields)) {
//.........这里部分代码省略.........
开发者ID:dalinhuang,项目名称:shopexts,代码行数:101,代码来源:PartuzaDbFetcher.php

示例2: __construct

/**
 * Created by PhpStorm.
 * User: roger
 * Date: 4/10/15
 * Time: 12:25
 */
class Person
{
    public $name;
    public $age;
    public function __construct($name)
    {
        $this->name = $name;
    }
    public function getAge($age)
    {
        return $this->age * 365;
    }
    public function setAge($age)
    {
        if ($age < 18) {
            throw new Exception("Es menor d'edat");
        }
        $this->age = $age;
    }
}
$john = new Person('John Doe');
$john->setAge(30);
$john->age = 3;
var_dump($john->getAge());
开发者ID:rogermelich,项目名称:Laracast_Exercicis,代码行数:30,代码来源:Person.php

示例3: __construct

<?php

/**
 * Created by PhpStorm.
 */
class Person
{
    public $name;
    public $age;
    public function __construct($name)
    {
        $this->name = $name;
    }
    public function getAge()
    {
        return $this->age * 365;
    }
    public function setAge($age)
    {
        if ($age < 18) {
            throw new Exception('Person is not old enough');
        }
        $this->age = $age;
    }
}
$john = new Person('John Doe');
$john->setAge('30');
$john->age = 3;
var_dump($john->getAge());
开发者ID:alexbonavila,项目名称:PHP_Exercicis,代码行数:29,代码来源:Person.php

示例4: __construct

<?php

/**
 * Created by PhpStorm.
 * User: oscar
 * Date: 08/10/2015
 * Time: 12:54
 */
class Person
{
    private $name;
    private $age;
    public function __construct($name)
    {
        $this->name = $name;
    }
    public function getAge()
    {
        return $this->age * 365;
    }
    public function setAge($age)
    {
        if ($age < 18) {
            throw new Exception("Es menor d'edat");
        }
        $this->age = $age;
    }
}
$Person = new Person('Pepe pepito');
$Person->setAge(19);
var_dump($Person->getAge());
开发者ID:OscarDuranX,项目名称:Exercicis_laracasts_Oscar,代码行数:31,代码来源:Person.php

示例5: getPersons

 public static function getPersons()
 {
     $dados = Database::ReadAll("person", "*");
     if (!$dados) {
         return '';
     }
     foreach ($dados as $dado) {
         $person = new Person();
         $person->setId($dado['ID_PERSON']);
         $person->setName($dado['NAME_PERSON']);
         $person->setEmail($dado['EMAIL']);
         $person->setAge($dado['AGE']);
         $person->setSex($dado['SEX']);
         $person->setPhone($dado['PHONE']);
         $person->setOperator($dado['OPERATOR']);
         $person->setMaritalStatus($dado['MARITAL_STATUS']);
         $person->setChildren($dado['CHILDREN']);
         $religion = Religion::getReligion("WHERE id_religion = " . $dado['ID_RELIGION']);
         $person->setReligion($religion);
         $address = Address::getAddress("AND id_address = " . $dado['ID_ADDRESS']);
         $person->setAddress($address);
         $login = Login::getLogin($dado['ID_PERSON']);
         $person->setLogin($login);
         $persons[] = $person;
     }
     return $persons;
 }
开发者ID:CarolinePaixao,项目名称:SCI,代码行数:27,代码来源:Person.php

示例6: Person

<?php

require_once 'Person.php';
session_start();
$p = new Person();
if ($_POST) {
    $p->setName($_POST['name']);
    $p->setAge($_POST['age']);
    $_SESSION['person'] = $p;
    header('Location:page2.php');
}
//if (isset($_POST['name'])) {
//    $_SESSION['name'] = $_POST['name'];
//    header('Location:page2.php');
//}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form action="" method="post">
    <label for="name">Name</label>
    <input type="text" name="name" id="name">

    <label for="age">Age</label>
    <input type="text" name="age" id="age">
开发者ID:gpichurov,项目名称:ittalents_season5,代码行数:30,代码来源:page1.php

示例7: Person

<?php

/**
 * Created by PhpStorm.
 * User: chrisbautista
 * Date: 2016-09-19
 * Time: 6:49 PM
 */
require "Person.php";
require "Employee.php";
require "Application.php";
$person = new Person();
$person->setAge(10);
$employee = new Employee();
$employee->setAge(30);
$app = new Application($person);
$app->run();
开发者ID:chrisbautista,项目名称:bcit-applied-development,代码行数:17,代码来源:index.php

示例8: testSetAge

 /**
  * Tests Person->setAge()
  */
 public function testSetAge()
 {
     $this->Person->setAge('age');
     $this->assertEquals('age', $this->Person->age);
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:8,代码来源:PersonTest.php

示例9: __construct

 * Created by PhpStorm.
 * User: Anam
 * Date: 6/20/2016
 * Time: 6:04 PM
 */
class Person
{
    private $name;
    private $age;
    public function __construct($name)
    {
        $this->name = $name;
    }
    public function getAge()
    {
        return $this->age;
    }
    public function setAge($age, $name)
    {
        echo ucfirst($name) . ' ,';
        if ($age < 18) {
            throw new Exception('person is not old enough');
        } else {
            echo 'you are 18+';
        }
        $this->age = $age;
    }
}
$person = new Person('john');
$person->setAge(12, 'jessica');
//var_dump($person->getAge());
开发者ID:anamwp,项目名称:My-Learning,代码行数:31,代码来源:class2.php

示例10: __construct

<?php

//Getters and Setters gives protection to your app
class Person
{
    private $name;
    private $age;
    public function __construct($name)
    {
        $this->name = $name;
    }
    public function setAge($age)
    {
        if ($age < 18) {
            throw new Exception("Person is not old enough.");
        }
        $this->age = $age * 365;
    }
    public function getName()
    {
        return $this->name;
    }
}
$jess = new Person('Jess');
$jess->setAge(30);
var_dump($jess);
开发者ID:vistajess,项目名称:playgroundz,代码行数:26,代码来源:getters_setters.php

示例11: __construct

<?php

class Person
{
    public function __construct($name)
    {
        $this->name = $name;
    }
    public function getAge()
    {
        return $this->age * 365;
    }
    public function setAge($age)
    {
        if ($age < 18) {
            throw new Exception('Person is not old enough.');
        }
        $this->age = $age;
    }
}
$john = new Person('John Doe');
$john->setAge(18);
var_dump($john->getAge());
开发者ID:ThomasNYoung,项目名称:laracast-projects,代码行数:23,代码来源:Personable.php

示例12: getPeople

 public function getPeople($ids, $fields, $options, $token)
 {
     $first = $options->getStartIndex();
     $max = $options->getCount();
     $this->checkDb();
     $ret = array();
     $filterQuery = '';
     if ($options->getFilterBy() == 'hasApp') {
         // remove the filterBy field, it's taken care of in the query already, otherwise filterResults will disqualify all results
         $options->setFilterBy(null);
         $appId = $token->getAppId();
         $filterQuery = " and id in (select person_id from person_applications where application_id = {$appId})";
     } elseif ($options->getFilterBy() == 'all') {
         $options->setFilterBy(null);
     } elseif ($options->getFilterBy() == '@friends') {
         $options->setFilterBy(null);
         $somePersonId = $options->getFilterValue();
         if ($options->getFilterValue() == '@viewer') {
             $somePersonId = $token->getViewerId();
         } elseif ($options->getFilterValue() == '@owner') {
             $somePersonId = $token->getOwnerId();
         }
         $filteredIds = array();
         foreach ($ids as $personId) {
             if (in_array($somePersonId, $this->getFriendIds($personId))) {
                 $filteredIds[] = $personId;
             }
         }
         $ids = $filteredIds;
     }
     $query = "select * from persons where id in (" . implode(',', $ids) . ") {$filterQuery} order by id ";
     $res = mysqli_query($this->db, $query);
     if ($res) {
         while ($row = @mysqli_fetch_array($res, MYSQLI_ASSOC)) {
             $person_id = $row['id'];
             $name = $this->convertName($row);
             $person = new Person($row['id'], $name);
             $person->setDisplayName($name->getFormatted());
             $person->setAboutMe($row['about_me']);
             $person->setAge($row['age']);
             $person->setChildren($row['children']);
             $person->setBirthday(date('Y-m-d', $row['date_of_birth']));
             $person->setEthnicity($row['ethnicity']);
             $person->setFashion($row['fashion']);
             $person->setHappiestWhen($row['happiest_when']);
             $person->setHumor($row['humor']);
             $person->setJobInterests($row['job_interests']);
             $person->setLivingArrangement($row['living_arrangement']);
             $person->setLookingFor($row['looking_for']);
             $person->setNickname($row['nickname']);
             $person->setPets($row['pets']);
             $person->setPoliticalViews($row['political_views']);
             $person->setProfileSong($row['profile_song']);
             $person->setProfileUrl($this->url_prefix . '/profile/' . $row['id']);
             $person->setProfileVideo($row['profile_video']);
             $person->setRelationshipStatus($row['relationship_status']);
             $person->setReligion($row['religion']);
             $person->setRomance($row['romance']);
             $person->setScaredOf($row['scared_of']);
             $person->setSexualOrientation($row['sexual_orientation']);
             $person->setStatus($row['status']);
             $person->setThumbnailUrl(!empty($row['thumbnail_url']) ? $this->url_prefix . $row['thumbnail_url'] : '');
             if (!empty($row['thumbnail_url'])) {
                 // also report thumbnail_url in standard photos field (this is the only photo supported by partuza)
                 $person->setPhotos(array(new Photo($this->url_prefix . $row['thumbnail_url'], 'thumbnail', true)));
             }
             $person->setUtcOffset(sprintf('%+03d:00', $row['time_zone']));
             // force "-00:00" utc-offset format
             if (!empty($row['drinker'])) {
                 $person->setDrinker($row['drinker']);
             }
             if (!empty($row['gender'])) {
                 $person->setGender(strtolower($row['gender']));
             }
             if (!empty($row['smoker'])) {
                 $person->setSmoker($row['smoker']);
             }
             /* the following fields require additional queries so are only executed if requested */
             if (isset($fields['activities']) || in_array('@all', $fields)) {
                 $activities = array();
                 $res2 = mysqli_query($this->db, "select activity from person_activities where person_id = " . $person_id);
                 while (list($activity) = @mysqli_fetch_row($res2)) {
                     $activities[] = $activity;
                 }
                 $person->setActivities($activities);
             }
             if (isset($fields['addresses']) || in_array('@all', $fields)) {
                 $addresses = array();
                 $res2 = mysqli_query($this->db, "select addresses.* from person_addresses, addresses where addresses.id = person_addresses.address_id and person_addresses.person_id = " . $person_id);
                 while ($row = @mysqli_fetch_array($res2, MYSQLI_ASSOC)) {
                     $address = $this->convertAddress($row);
                     //FIXME quick and dirty hack to demo PC
                     $address->setPrimary(true);
                     $addresses[] = $address;
                 }
                 $person->setAddresses($addresses);
             }
             if (isset($fields['bodyType']) || in_array('@all', $fields)) {
                 $res2 = mysqli_query($this->db, "select * from person_body_type where person_id = " . $person_id);
                 if (@mysqli_num_rows($res2)) {
//.........这里部分代码省略.........
开发者ID:vuxuandung,项目名称:Partuza-bundle,代码行数:101,代码来源:PartuzaDbFetcher.php

示例13: getPeople

 public function getPeople($ids, $fields, $options, $token)
 {
     $first = $options->getStartIndex();
     $max = $options->getCount();
     $this->checkDb();
     $ret = array();
     $filterQuery = '';
     if ($options->getFilterBy() == 'hasApp') {
         // remove the filterBy field, it's taken care of in the query already, otherwise filterResults will disqualify all results
         $options->setFilterBy(null);
         $appId = $token->getAppId();
         $filterQuery = " and id in (select member_id from " . TABLE_PREFIX . "social_applications where application_id = {$appId})";
     } elseif ($options->getFilterBy() == 'all') {
         $options->setFilterBy(null);
     }
     $query = "SELECT member.*, info.interests, info.associations, info.awards FROM " . TABLE_PREFIX . "members member LEFT JOIN " . TABLE_PREFIX . "social_member_additional_information info ON member.member_id=info.member_id WHERE  member.member_id IN (" . implode(',', $ids) . ") {$filterQuery} ORDER BY member.member_id ";
     $res = mysql_query($query, $this->db);
     if ($res) {
         while ($row = mysql_fetch_assoc($res)) {
             $member_id = intval($row['member_id']);
             $name = new Name($row['first_name'] . ' ' . $row['last_name']);
             $name->setGivenName($row['first_name']);
             $name->setFamilyName($row['last_name']);
             $person = new Person($row['member_id'], $name);
             $person->setDisplayName($name->getFormatted());
             $person->setAboutMe($row['about_me']);
             $person->setAge($row['age']);
             $person->setChildren($row['children']);
             $person->setBirthday(date('Y-m-d', $row['date_of_birth']));
             $person->setEthnicity($row['ethnicity']);
             $person->setFashion($row['fashion']);
             $person->setHappiestWhen($row['happiest_when']);
             $person->setHumor($row['humor']);
             $person->setJobInterests($row['job_interests']);
             $person->setLivingArrangement($row['living_arrangement']);
             $person->setLookingFor($row['looking_for']);
             $person->setNickname($row['nickname']);
             $person->setPets($row['pets']);
             $person->setPoliticalViews($row['political_views']);
             $person->setProfileSong($row['profile_song']);
             $person->setProfileUrl($this->url_prefix . '/profile/' . $row['member_id']);
             $person->setProfileVideo($row['profile_video']);
             $person->setRelationshipStatus($row['relationship_status']);
             $person->setReligion($row['religion']);
             $person->setRomance($row['romance']);
             $person->setScaredOf($row['scared_of']);
             $person->setSexualOrientation($row['sexual_orientation']);
             $person->setStatus($row['status']);
             $person->setThumbnailUrl(!empty($row['thumbnail_url']) ? $this->url_prefix . $row['thumbnail_url'] : '');
             if (!empty($row['thumbnail_url'])) {
                 // also report thumbnail_url in standard photos field (this is the only photo supported by ATutor)
                 $person->setPhotos(array(new Photo($this->url_prefix . 'get_profile_img.php?id=' . $row['member_id'], 'thumbnail', true)));
             }
             $person->setUtcOffset(sprintf('%+03d:00', $row['time_zone']));
             // force "-00:00" utc-offset format
             if (!empty($row['drinker'])) {
                 $person->setDrinker($row['drinker']);
             }
             if (!empty($row['gender'])) {
                 $person->setGender(strtolower($row['gender']));
             }
             if (!empty($row['email'])) {
                 //TODO: Assumed <static> object TYPE to be "home".  Change it if ATutor starts accepting more than one email
                 $email = new Email(strtolower($row['email']), 'home');
                 $person->setEmails($email);
             }
             if (!empty($row['interests'])) {
                 $strings = explode(',', $row['interests']);
                 $person->setInterests($strings);
             }
             //TODO: Not in ATutor yet, skeleton field
             if (!empty($row['smoker'])) {
                 $person->setSmoker($row['smoker']);
             }
             /* the following fields require additional queries so are only executed if requested */
             if (isset($fields['activities']) || isset($fields['@all'])) {
                 $activities = array();
                 $sql = "select title from " . TABLE_PREFIX . "social_activities where member_id = " . $member_id;
                 $res2 = mysql_query($sql, $this->db);
                 while (list($activity) = mysql_fetch_row($res2)) {
                     $activities[] = $activity;
                 }
                 $person->setActivities($activities);
             }
             if (isset($fields['addresses']) || isset($fields['@all'])) {
                 $addresses = array();
                 $sql = "select address, postal, city, province, country from " . TABLE_PREFIX . "members m where m.member_id = " . $member_id;
                 $res2 = mysql_query($sql, $this->db);
                 while ($row = mysql_fetch_assoc($res2)) {
                     if (empty($row['unstructured_address'])) {
                         $row['unstructured_address'] = trim($row['street_address'] . " " . $row['province'] . " " . $row['country']);
                     }
                     $addres = new Address($row['unstructured_address']);
                     $addres->setCountry($row['country']);
                     $addres->setLatitude($row['latitude']);
                     $addres->setLongitude($row['longitude']);
                     $addres->setLocality($row['locality']);
                     $addres->setPostalCode($row['postal_code']);
                     $addres->setRegion($row['province']);
                     $addres->setStreetAddress($row['street_address']);
//.........这里部分代码省略.........
开发者ID:vicentborja,项目名称:ATutor,代码行数:101,代码来源:ATutorDbFetcher.php

示例14: __construct

<?php

class Person
{
    private $name;
    private $age;
    public function __construct($name)
    {
        $this->name = $name;
    }
    public function getAge()
    {
        return $this->age * 365;
    }
    public function setAge($age)
    {
        if ($age < 17) {
            throw new Exception('You are not old enough!');
        }
        $this->age = $age;
    }
}
$shahbaaz = new Person('Shahbaaz Hussain');
$shahbaaz->setAge('32');
$shahbaaz->age = '33';
// cannot access private property error
// var_dump($shahbaaz->getAge());
var_dump($shahbaaz);
开发者ID:shahbaaz,项目名称:practice,代码行数:28,代码来源:person.php

示例15: __construct

<?php

class Person
{
    public $name;
    public $age;
    public function __construct($name)
    {
        $this->name = $name;
    }
    public function getAge()
    {
        return $this->age * 365;
    }
    public function setAge($age)
    {
        if ($age < 18) {
            throw new Exception("Person is not old enough.");
        }
        $this->age = $age;
    }
}
$steven = new Person("Steven Jasionowicz");
$steven->setAge(26);
var_dump($steven->getAge());
开发者ID:codeandrockets,项目名称:laracasts,代码行数:25,代码来源:gettersandsetters.php


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