/** * Test Unicode to Zawgyi converting. */ public function testUni2zgConverting() { foreach ($this->sampleStrings['uni'] as $index => $unicode) { $zawgyi = $this->sampleStrings['zg'][$index]; $this->assertSame($zawgyi, Rabbit::uni2zg($unicode)); } }
public function testObjectKeys() { $josephine = new Rabbit("Josephine"); $flopsy = new Rabbit("Flopsy"); $mopsy = new Rabbit("Mopsy"); $cottontail = new Rabbit("Cotton-tail"); $josephine->addChild($flopsy); $josephine->addChild($mopsy); $josephine->addChild($cottontail); $dict = new Dictionary(); $dict->put($josephine, "josephine"); $dict->put($flopsy, "flopsy"); $dict->put($mopsy, "mopsy"); $dict->put($cottontail, "cottontail"); $this->assertEquals("josephine", $dict->get($josephine)); $this->assertEquals("flopsy", $dict->get($flopsy)); $this->assertEquals("mopsy", $dict->get($mopsy)); $this->assertEquals("cottontail", $dict->get($cottontail)); }
<?php /** * 预热后2千万的关键词 */ $Rabbit = new Rabbit(); $Rabbit->run(); class Rabbit { public $type = 'OnlinePro'; public function __construct() { } public function run() { $method = "run" . $this->type; $this->{$method}(); } public function runcom() { $kid = 0; while (1) { $this->local189 = new Table("local189"); $keywordRs = $this->local189->findAll("select kid, keyword from gckeyword.key_comkeyword where kid > '{$kid}' and is_edit >= 0 order by kid asc limit 100"); if (empty($keywordRs)) { break; } foreach ($keywordRs as $keyword) { $kid = $keyword['kid']; echo $keyword['keyword']; echo "\n";
static function addQueue($data, $code, $details) { if (empty($_GET)) { $args = $_POST; } else { $args = $_GET; } //得到actionID if (empty($_SERVER['REQUEST_URI'])) { $action = ''; } else { $action = $_SERVER['REQUEST_URI']; } //得到sessionID if (empty($args['session_id'])) { $sessionID = ''; $uniqueUserID = -1; } else { $sessionID = $args['session_id']; $uniqueUserID = TZ_Loader::service('SessionManager', 'User')->getUid($sessionID); } $rabbitMq = new Rabbit(); $rabbitMq->addCallLog($action, $uniqueUserID, $sessionID, $code, $details, $args, $data); }
<?php class Animal { public function hasHead() { return true; } } class Rabbit extends Animal { public function hasFur() { return true; } public function eatsCarrots() { return true; } } $r = new Rabbit(); $h = $r->hasHead(); $f = $r->hasFur();
<?php class Animal { function hasHead() { return true; } } class FurryAnimal extends Animal { function hasFur() { return true; } } class Rabbit extends FurryAnimal { function isCute() { return true; } } $r = new Rabbit(); $r->hasHead(); $r->hasFur(); $r->isCute();
/** * Send notifications about completed action * @param string $message Notification message * @return bool */ public function notify($message) { $this->logger->info('Node notification sent', ['nodeName' => $this->name, 'notifyType' => 'complete']); return $this->rabbit->write($message, $this->name . '_notify'); }
<?php /** * Created by PhpStorm. * User: bamdad * Date: 2/3/2016 * Time: 9:02 PM */ include_once './autoload.php'; $bunbun = new Rabbit('bunbun'); $bunbun->speak(); $bunbun->eat(30); $bunbun->eat(30); ///Dice $die = new MyDie(8); echo "simple die roll: " . $die->roll() . "\n"; $no1 = new FirstSichermanDice(); echo "no1 roll: " . $no1->roll() . "\n"; $no2 = new SecondSichermanDice(); echo "no2 roll: " . $no2->roll() . "\n"; //Bottles $bottle1 = new ChampagneBottle(); $bottle1->pour(); $bottle2 = new CheatBottle(); $bottle2->pour(); $bottle2->pour(); $bottle2->pour();