本文整理汇总了PHP中Foo::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Foo::get方法的具体用法?PHP Foo::get怎么用?PHP Foo::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foo
的用法示例。
在下文中一共展示了Foo::get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBar
<?php
set_include_path(dirname(__FILE__) . '/../../../../');
require_once 'limb/core/common.inc.php';
require_once 'limb/core/src/lmbObject.class.php';
class Foo extends lmbObject
{
function getBar()
{
return 'bar';
}
}
$object = new Foo(array('foo' => 'foo'));
// heating_up
for ($i = 0; $i < 1000; $i++) {
$object->get('foo');
}
$mark = microtime(true);
for ($i = 0; $i < 1000; $i++) {
$object->get('foo');
}
echo "get('foo'): " . (microtime(true) - $mark) . "\n";
$mark = microtime(true);
for ($i = 0; $i < 1000; $i++) {
$object->get('bar');
}
echo "get('bar') => getBar(): " . (microtime(true) - $mark) . "\n";
$mark = microtime(true);
for ($i = 0; $i < 1000; $i++) {
$object->getBar();
}
示例2: testUnset
public function testUnset()
{
$foo = Foo::get('foo3');
$this->assertEquals(2, count($foo->bars));
$this->assertEquals('Bar 1', $foo->bars[0]->barbar);
$this->assertEquals('Bar 2', $foo->bars[1]->barbar);
unset($foo->bars[0]);
$foo = Foo::get('foo3');
$bar = Bar::get('bar 1');
$this->assertEquals(1, count($foo->bars));
$this->assertEquals('Bar 2', $foo->bars[0]->barbar);
$this->assertEquals(1, count($bar->foos));
$this->assertEquals('Foo 2', $bar->foos[0]->foofoo);
}
示例3: of
}
public function of($target)
{
return HermitDaoManager::get($target);
}
}
class Foo
{
public function get()
{
return HermitDaoManager::get(__CLASS__);
}
}
class Bar
{
public function get()
{
return HermitDaoManager::get(__CLASS__);
}
}
$hoge = new Hoge();
$foo = new Foo();
$bar = new Bar();
$test->is($hoge->get(), 'A01Dao');
$test->is($hoge->of('Foo'), 'A02Dao');
$test->is($foo->get(), 'A02Dao');
$test->is($bar->get(), null);
$test->is(HermitDaoManager::has('Hoge'), true);
$test->is(HermitDaoManager::has('Foo'), true);
$test->is(HermitDaoManager::has('A01Dao'), false);
$test->is(HermitDaoManager::has('A02Dao'), false);
示例4: var_dump
var_dump($persond);
var_dump($person3);
class Foo
{
protected static $prop = 'Foo';
public static function get()
{
echo static::$prop;
// Если бы тут был self то наследуемый класс тоже давал бы Foo
}
}
class Bar extends Foo
{
protected static $prop = 'Bar';
}
Foo::get();
Bar::get();
class Team
{
protected $developers = [];
// Всегда лучше всё закрывать, то есть лучше использовать protected
// Сначала всё закрывать, потом открывать
public function addDeveloper(Developer $developer)
{
array_push($this->developers, $developer);
}
}
$team = new Team();
//$team->addDeveloper($person);
$team->addDeveloper($person3);
//$team->addDeveloper(666);
示例5: function
<?php
Route::get('user/profile', ['as' => 'profile1']);
Route::get('user/profile', ['as' => 'profile2', function () {
}]);
Route::get('user/profile', ['as' => 'profile3', 'uses' => 'UserController@showProfile']);
Route::get('user/profile', 'UserController@showProfile')->name('profile4');
Foo::get('user/profile', 'UserController@showProfile')->name('foo');
Foo::get('user/profile', ['as' => 'bar']);
示例6: testBatchSave
public function testBatchSave()
{
$foo = new Foo;
$foo->ID = 'SomeFoo';
// No foofoo -> invalid
$bar = new Bar;
$bar->ID = 'Somebar';
$bar->barbar = '...';
$bar->foo = $foo;
try
{
DBModel::batchSave(array($foo, $bar));
$this->fail('Expected exception');
}
catch (ValidationException $e)
{
$bar2 = Bar::get('Somebar');
$foo2 = Foo::get('SomeFoo');
$this->assertNull($bar2);
$this->assertNull($foo2);
$this->assertEquals('FooFoo is required', $foo->foofoo_error);
}
}
示例7: Foo
<?php
use js\tools\commons\traits\DataWriter;
use js\tools\commons\traits\StaticDataWriter;
require __DIR__ . '/../autoloader.php';
class Foo
{
use DataWriter;
}
class Bar
{
use StaticDataWriter;
}
$foo = new Foo();
$foo->set('a.b.c', 'foo');
var_dump($foo->getArray('a.b'));
var_dump($foo->get('a.b.c'));
Bar::set('a.b.c', 'bar');
var_dump(Bar::getArray('a.b'));
var_dump(Bar::get('a.b.c'));