• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Animal类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_getAnimals

 function test_getAnimals()
 {
     //Arrange
     $type = "dog";
     $id = null;
     $test_animal_type = new AnimalType($type, $id);
     $test_animal_type->save();
     $test_type_id = $test_animal_type->getId();
     $name = 'Sparky';
     $gender = 'Male';
     $breed = 'Pug';
     $admit_date = '2015-08-18';
     $test_animal = new Animal($name, $gender, $breed, $admit_date, $test_type_id);
     $test_animal->save();
     $name2 = 'Senna';
     $gender2 = 'Male';
     $breed2 = 'Domestic Shorthair';
     $admit_date2 = '2015-07-28';
     $test_animal2 = new Animal($name, $gender, $breed, $admit_date, $test_type_id);
     $test_animal2->save();
     //Act
     $result = $test_animal_type->getAnimals();
     //Assert
     $this->assertEquals([$test_animal, $test_animal2], $result);
 }
开发者ID:slmaturen,项目名称:animal-shelter,代码行数:25,代码来源:AnimalTypeTest.php


示例2: perigo

 public function perigo(Animal $p)
 {
     $p->emitirSom();
     $p->dormir();
     //$p->brincar(); Nao vale para todos
     //os animais.
 }
开发者ID:vitorgja,项目名称:Fatec-rl,代码行数:7,代码来源:de_subtipo.php


示例3: getListCountryCityCountryLanguage

 function getListCountryCityCountryLanguage($condicion = null, $parametros = array())
 {
     if ($condicion === null) {
         $condicion = "";
     } else {
         $condicion = "where {$condicion}";
     }
     $sql = " select co.*, ci.*, cl.*\r\n                    from country co\r\n                    left join city ci\r\n                    on co.Code = ci.CountryCode\r\n                    left join countrylanguage cl \r\n                    on co.Code =  cl.CountryCode {$condicion}";
     $this->bd->send($sql, $parametros);
     $r = array();
     $contador = 0;
     while ($fila = $this->bd->getRow()) {
         $country = new Cuidador();
         $country->set($fila);
         $city = new Animal();
         $city->set($fila, 15);
         //el numero es a partir del ultimo campo de country, para que coja los de city
         //$countrylanguage = new CountryLanguage();
         //$countrylanguage->set($fila, 20);
         $r[$contador]["country"] = $country;
         $r[$contador]["city"] = $city;
         //$r[$contador]["countrylanguage"]=$countrylanguage;
         $contador++;
     }
     return $r;
 }
开发者ID:jcfuentes102,项目名称:ZOO,代码行数:26,代码来源:ManageRelations.php


示例4: removeAnimal

 public function removeAnimal(Animal $animal)
 {
     foreach ($this->_group as $key => $current) {
         if ($current->getAnimalName() == $animal->getAnimalName()) {
             unset($this->_group[$key]);
         }
     }
 }
开发者ID:azurecorn,项目名称:animal_farm,代码行数:8,代码来源:AnimalGroup.php


示例5: enqueue

 public function enqueue(Animal $animal)
 {
     $animal->setIndex($this->index++);
     if ($animal instanceof Dog) {
         $this->dogs->add($animal);
     } else {
         if ($animal instanceof Cat) {
             $this->cats->add($animal);
         } else {
             throw new InvalidArgumentException('Unknown animal type: ' + get_class($animal));
         }
     }
 }
开发者ID:SamyGhannad,项目名称:CtCI-6th-Edition,代码行数:13,代码来源:AnimalShelter.php


示例6: register

 public function register($aid, $name, $gender, $age, $type, $u_name, $u_gender, $u_city, $inviter)
 {
     $user = new User();
     $user->name = $u_name;
     $user->gender = $u_gender;
     $user->city = $u_city;
     $user->code = $this->createInviteCode();
     $user->inviter = $inviter;
     $user->gold = 500;
     $reward_items = array(1101 => 3, 1102 => 3, 1103 => 3, 1104 => 3, 1105 => 3, 1106 => 3, 1107 => 3, 1201 => 2, 1202 => 2, 1203 => 2, 1204 => 2, 1205 => 2, 1206 => 2, 1207 => 2, 1301 => 1, 1302 => 1, 1303 => 1, 1304 => 1, 1305 => 1, 2101 => 3, 2102 => 3, 2103 => 3, 2104 => 3);
     $user->items = serialize($reward_items);
     $user->save();
     if (!isset($aid)) {
         $animal = new Animal();
         $animal->name = $name;
         $animal->gender = $gender;
         $animal->age = $age;
         $animal->type = $type;
         $animal->from = substr($type, 0, 1);
         $animal->master_id = $user->usr_id;
         $animal->save();
         $aid = $animal->aid;
         $circle = new Circle();
         $circle->aid = $aid;
         $circle->usr_id = $user->usr_id;
         $circle->rank = 0;
         $circle->save();
     } else {
         $circle = new Circle();
         $circle->aid = $aid;
         $circle->usr_id = $user->usr_id;
         $circle->save();
     }
     $f = new Follow();
     $f->usr_id = $user->usr_id;
     $f->aid = $aid;
     $f->create_time = time();
     $f->save();
     $user->aid = $aid;
     $user->saveAttributes(array('aid'));
     $user->initialize();
     $user->rewardInviter();
     //$this->onRegister = array($user, 'initialize');
     //$this->onRegister = array($user, 'rewardInviter');
     $this->owner->usr_id = $user->usr_id;
     $this->owner->saveAttributes(array('usr_id'));
     $this->onRegister(new CEvent());
     return $user;
 }
开发者ID:sr71k,项目名称:pet,代码行数:49,代码来源:DeviceBehavior.php


示例7: getList

 function getList($pagina = 1, $orden = "", $nrpp = Constant::NRPP)
 {
     $ordenPredeterminado = "{$orden}, NombreAnimal, ZonaCode, IDAnimal";
     if ($orden === "" || $orden === null) {
         $ordenPredeterminado = "NombreAnimal, ZonaCode, IDAnimal";
     }
     $registroInicial = ($pagina - 1) * $nrpp;
     $this->bd->select($this->tabla, "*", "1=1", array(), $ordenPredeterminado, "{$registroInicial}, {$nrpp}");
     $r = array();
     while ($fila = $this->bd->getRow()) {
         $animal = new Animal();
         $animal->set($fila);
         $r[] = $animal;
     }
     return $r;
 }
开发者ID:jcfuentes102,项目名称:ZOO,代码行数:16,代码来源:ManageAnimal.php


示例8: deleteAnimal

 public static function deleteAnimal($ìd)
 {
     try {
         Animal::delete($id);
         echo 'Animal excluído';
     } catch (PDOException $e) {
         echo 'Houve um erro: ' . $e;
     }
 }
开发者ID:vncdias,项目名称:missao-simplesvet,代码行数:9,代码来源:AnimalController.php


示例9: getListCountryCityCountryLanguage

 function getListCountryCityCountryLanguage($condicion = null, $parametros = array())
 {
     if ($condicion === null) {
         $condicion = "";
     } else {
         $condicion = "where {$condicion}";
     }
     $sql = " select co.*, ci.*, cl.*\r\n                    from country co\r\n                    left join city ci\r\n                    on co.Code = ci.CountryCode\r\n                    left join countrylanguage cl \r\n                    on co.Code =  cl.CountryCode {$condicion}";
     $this->bd->send($sql, $parametros);
     $r = array();
     while ($fila = $this->bd->getRow()) {
         $country = new Cuidador();
         $country->set($fila);
         $city = new Animal();
         $city->set($fila, 15);
         $countrylanguage = new CountryLanguage();
         $countrylanguage->set($fila, 20);
         $r[] = new CountryCityCountryLanguage($country, $city, $countrylanguage);
     }
     return $r;
 }
开发者ID:jcfuentes102,项目名称:ZOO,代码行数:21,代码来源:CountryCityCountryLanguage.php


示例10: testBatchWrite_NestedObjects_ObjectsExist

 /**
  *
  */
 public function testBatchWrite_NestedObjects_ObjectsExist()
 {
     $dogs = array();
     for ($i = 0; $i < 100; $i++) {
         $dog = new Dog();
         $dog->Name = 'Bob ' . $i;
         $dog->Country = 'Africa ' . $i;
         $dog->Type = 'Woof Dog ' . $i;
         $dog->Color = 'Brown #' . $i;
         $dogs[] = $dog;
     }
     $batch = new \Batch();
     $batch->write($dogs);
     for ($i = 0; $i < 100; $i++) {
         $this->assertTrue($dogs[$i]->exists());
         $id = $dogs[$i]->ID;
         $this->assertEquals($i + 1, $id);
     }
     $this->assertEquals(100, Dog::get()->count());
     foreach (Animal::get() as $i => $dog) {
         $this->assertEquals('Bob ' . $i, $dog->Name);
         $this->assertEquals('Brown #' . $i, $dog->Color);
     }
 }
开发者ID:helpfulrobot,项目名称:littlegiant-silverstripe-batchwrite,代码行数:27,代码来源:BatchWriteTest.php


示例11: getHomelessAnimals

 /**
  * @return la liste des animaux à l'adoption
  */
 public static function getHomelessAnimals()
 {
     $db = DbManager::getPDO();
     $query = "SELECT * FROM Animal WHERE idState='" . self::$STATE_ADOPTION . "';";
     $res = $db->query($query)->fetchAll();
     for ($i = 0; $i < count($res); $i++) {
         $animal = Animal::getAnimalArrayFromFetch($res[$i]);
         $listAnimals[$animal['idAnimal']] = $animal;
     }
     return $listAnimals;
 }
开发者ID:Gouga34,项目名称:Server,代码行数:14,代码来源:Animal.php


示例12: __autoload

<?php

function __autoload($className)
{
    require_once $className . '-class.php';
}
// ANIMAL CLASS
$kikker = new Animal('Kermit', 'male', 100);
$kat = new Animal('Dikkie', 'male', 100);
$kat->changeHealth(-10);
$dolfijn = new Animal('Flipper', 'female', 80);
?>


<!DOCTYPE html>
<html>
<head>
	<title>Oplossing PHPoefening 040</title>
</head>
	<body>
	

		<h1>Oplossing PHPoefening 040</h1>
		
		
		<p><?php 
echo $kikker->getName();
?>
 is van het geslacht <?php 
echo $kikker->getSex();
?>
开发者ID:gurbuzhasan,项目名称:web-backend,代码行数:31,代码来源:phpoefening-040-a-oplossing.php


示例13: __autoload

<?php

/*   Load in classes     */
function __autoload($className)
{
    require 'classes/' . $className . '.php';
}
/*   Create instance of class Animal: $cat = new Animal("Name", "Gender","health");   */
$cat = new Animal("Buttons", "Male", 50);
$hippo = new Animal("Ms Hippo", "Female", 1000);
$flamingo = new Animal("Firenze", "Male", 200);
$hippo->changeHealth(-200);
/*  Create instance of class lion & zebra  */
$Lionel = new Lion("Lionel", "Male", 500, "Cool lion");
$Lionesse = new Lion("Lionesse", "Female", 400, "Awesome lion");
$Zebradude = new Zebra("Zebradude", "Male", 500, "Fast zebra");
$Zebradudette = new Zebra("Zebradudette", "Female", 300, "Good looking zebra");
?>

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Opdracht classes: extends</title>
        <link rel="stylesheet" href="http://web-backend.local/css/global.css">
        <link rel="stylesheet" href="http://web-backend.local/css/facade.css">
        <link rel="stylesheet" href="http://web-backend.local/css/directory.css">
    </head>
    <body class="web-backend-opdracht">
        
开发者ID:RobinDeHerdt,项目名称:web-backend-oplossingen,代码行数:30,代码来源:application.php


示例14: __autoload

<?php

function __autoload($className)
{
    include "classes/" . $className . ".php";
}
/*
__autoload("Animal");
__autoload("Lion");*/
$lion = new Animal("johan", "man", 10);
$cat = new Animal("bert", "vrouw", 50);
$dog = new Animal("Gerrit", "man", 24);
$simba = new Lion("lion", "Simba", "vrouw", 12);
$scar = new Lion("mountain lion", "scar", "man", 150);
$zeke = new Zebra("Leke", "man", 57421, "zebra");
$Brian = new Zebra("Bian", "vrouw", 5742, "zebra");
$lion->changeHealth(20);
?>

<!doctype html>
<html>
	<head>
		<title>Opdracht classes-extends</title>

	</head>

<body>

	<h1>Instanties van de classe Animal</h1>

	<p><?php 
开发者ID:sepperenty,项目名称:web-backend-oplossingen,代码行数:31,代码来源:application.php


示例15: __autoload

<!doctype html>

<?php 
function __autoload($className)
{
    require_once 'classes/' . $className . '.php';
}
// ANIMAL CLASS
$rat = new Animal('Lou', 'male', 100);
$kat = new Animal('Dik', 'female', 100);
$koe = new Animal('Mia', 'female', 80);
$kat->changeHealth(-10);
$koe->changeHealth(+5);
// LION CLASS
$simba = new lion('Simba', 'male', 100, 'Congo lion');
$scar = new lion('Scar', 'female', 100, 'Kenia lion');
// ZEBRA CLASS
$zeke = new zebra('Zeke', 'male', 120, 'Quagga');
$zana = new zebra('Zana', 'female', 100, 'Selous');
?>

<html>
<head>
<meta charset="utf-8">
<title>Naamloos document</title>
</head>

<body>

<h1>Opdracht classes extends</h1>
开发者ID:stoicsteve,项目名称:web-backend-oplossingen,代码行数:30,代码来源:application.php


示例16: treat

 public function treat(Animal $animal)
 {
     echo 'The vet has treated ' . $animal->getName();
 }
开发者ID:anatai,项目名称:manray,代码行数:4,代码来源:example3.php


示例17: unlink

            unlink(DBDIR . "animals/{$args['0']}");
        } else {
            throw new ERR_NOT_FOUND("Sorry, the barn does not contain {$args['0']}.");
        }
        $resp->status()->add_message("{$args['0']} is now dead. Good job!");
        return Worker::WORKER_SUCCESS;
    }
    function do_work($id, $resp)
    {
        $animal = $this->get_animal($id);
        if ($animal['species'] == 'Araneus cavaticus') {
            $this->spin_web($animal['name'], $resp);
        } else {
            $resp->status()->add_message($animal['name'] . " is happily rolling around in the mud!");
        }
    }
    function spin_web($name, $resp)
    {
        $resp->status()->progress(10);
        $resp->status()->add_message("{$name} is beginning to spin a web.");
        sleep(30);
        $resp->status()->progress(50);
        $resp->status()->add_message("{$name} is still spinning...");
        sleep(30);
        $messages = array('SOME PIG', 'TERRIFIC', 'RADIANT', 'HUMBLE');
        $message = $messages[array_rand($messages)];
        $resp->status()->add_message("{$name}'s web is complete! It says: '{$message}'");
    }
}
$worker = new Animal($argv[1]);
$worker->run();
开发者ID:wqx081,项目名称:gearbox,代码行数:31,代码来源:workerBarn.php


示例18: actionModifyInfoApi

 public function actionModifyInfoApi($aid, $name, $gender, $age, $type)
 {
     $pattern = '/^[a-zA-Z0-9\\x{30A0}-\\x{30FF}\\x{3040}-\\x{309F}\\x{4E00}-\\x{9FBF}]+$/u';
     //$namelen = (strlen($name)+mb_strlen($name,"UTF8"))/2;
     $namelen = mb_strlen($name, "UTF8");
     if ($namelen > 8) {
         throw new PException('宠物昵称超过最大长度');
     }
     if (!preg_match($pattern, $name)) {
         throw new PException('宠物昵称含有特殊字符');
     }
     $transaction = Yii::app()->db->beginTransaction();
     try {
         $animal = Animal::model()->findByPk($aid);
         $animal->name = $name;
         $animal->age = $age;
         $animal->type = $type;
         $animal->gender = $gender;
         $animal->saveAttributes(array('name', 'age', 'type', 'gender'));
         $transaction->commit();
         $this->echoJsonData(array('isSuccess' => true));
     } catch (Exception $e) {
         $transaction->rollback();
         throw $e;
     }
 }
开发者ID:sr71k,项目名称:pet,代码行数:26,代码来源:AnimalController.php


示例19: somAnimalFaz

            }
            function somAnimalFaz()
            {
                return 'O animal ' . $this->animal . ' faz o seguinte som:  ' . $this->som . '.<br/>';
            }
        };
    }
    function exibeMenagemSomAnimal()
    {
        return $this->name->somAnimalFaz();
    }
}
$meuPetA = new Animal("Gato", "Mia");
echo $meuPetA->exibeMenagemSomAnimal();
$meuPetB = new Animal("Cachorro", "Late");
echo $meuPetB->exibeMenagemSomAnimal();
$meuPetC = new Animal("Tico Francisco", "Canta");
echo $meuPetC->exibeMenagemSomAnimal();
?>

            </div>

            <div class="footer">
                <?php 
include 'views/partials/footer.php';
?>
            </div>
        </div>
    </body>

开发者ID:ronaldfalcao,项目名称:novidades-php7,代码行数:29,代码来源:index.php


示例20: describe

 public function describe()
 {
     $parentValue = parent::describe();
     //$parentValue .= $this->ssn;
     return $parentValue . ' but I am really a dog';
     //return parent::describe();
 }
开发者ID:sameg14,项目名称:php-mastery-code,代码行数:7,代码来源:animals.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Annotation类代码示例发布时间:2022-05-23
下一篇:
PHP Anchors类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap