本文整理匯總了PHP中Foo::getBar方法的典型用法代碼示例。如果您正苦於以下問題:PHP Foo::getBar方法的具體用法?PHP Foo::getBar怎麽用?PHP Foo::getBar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Foo
的用法示例。
在下文中一共展示了Foo::getBar方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Foo
}
$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();
}
echo "instance getBar(): " . (microtime(true) - $mark) . "\n";
$mark = microtime(true);
for ($i = 0; $i < 1000; $i++) {
$object->getFoo();
}
echo "dynamic getFoo(): " . (microtime(true) - $mark) . "\n";
$mark = microtime(true);
for ($i = 0; $i < 1000; $i++) {
$object->foo;
}
echo "->foo: " . (microtime(true) - $mark) . "\n";
示例2: __construct
<?php
/**
* GitHub Issue: https://github.com/ejmr/php-mode/issues/53
*
* Test if switching from Drupal coding style to other coding styles updates
* the whitespace effects.
*
* This file contains arbitrary PHP code with some whitespace added to the end
* of some lines.
*
*/
class Foo
{
private $bar;
public function __construct($bar)
{
$this->bar = $bar;
}
public function getBar()
{
// here is the whitespace
return $this->bar;
}
}
$foo = new Foo('bar');
$bar = $foo->getBar();