本文整理汇总了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();