本文整理汇总了PHP中foo类的典型用法代码示例。如果您正苦于以下问题:PHP foo类的具体用法?PHP foo怎么用?PHP foo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了foo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: barfunc
public function barfunc()
{
// funcdef 1
$x = new foo();
// call 0
$x->foofunc();
// call 1
}
示例2: bar
function bar()
{
print "calling foo statically:\n";
foo::func();
print "calling foo dynamically:\n";
$foo = new foo();
$foo->func();
print "done\n";
}
示例3: foo
function foo($bla)
{
$array = array('key' => 'value', 'anotherKey' => 'anotherValue');
echo 'foo';
foo::foo($param1, $param2);
$this->foo($param3, $param4);
somefunc($param5, $param6);
}
示例4: test
public function test()
{
call_user_func(array('FOO', 'ABC'));
call_user_func(array($this, 'ABC'));
foo::XYZ();
self::WWW();
call_user_func('FOO::ABC');
}
示例5: mul
echo "b = " . $this->b . "\n";
}
function mul()
{
return $this->a * $this->b;
}
}
class bar extends foo
{
public $c;
function display()
{
/* alternative display function for class bar */
echo "This is class bar\n";
echo "a = " . $this->a . "\n";
echo "b = " . $this->b . "\n";
echo "c = " . $this->c . "\n";
}
}
$foo1 = new foo();
$foo1->a = 2;
$foo1->b = 5;
$foo1->display();
echo $foo1->mul() . "\n";
echo "-----\n";
$bar1 = new bar();
$bar1->a = 4;
$bar1->b = 3;
$bar1->c = 12;
$bar1->display();
echo $bar1->mul() . "\n";
示例6: func
$d = 10;
$d = func($a, $b);
exit;
}
if ($which == 1) {
/**
* 返回引用示例1
*/
class foo
{
public $value = 20;
function &getValue()
{
return $this->value;
}
}
$obj = new foo();
$value =& $obj->getValue();
// test 2:
$obj->value = 30;
echo $value;
exit;
// test 1:
$value = 30;
echo $obj->value;
exit;
}
$a = '100';
$b =& $a;
$b = 200;
echo $a;
示例7: as_string
<?php
class foo
{
public $foo = 1;
function as_string()
{
assert('$this->foo == 1');
}
function as_expr()
{
assert($this->foo == 1);
}
}
$foo = new foo();
$foo->as_expr();
$foo->as_string();
示例8: foo
{
public $prop = 'a value';
function foo($arg)
{
print "Constructor called on {$arg}\n";
}
function method()
{
print "Method called\n";
return $this;
}
function method2()
{
print "Method 2 called\n";
return $this;
}
}
$foo = new foo('an argument');
$foo->method()->method();
// Can you do it on properties too?
print "property is :" . $foo->method()->prop . "\n";
$foo->method()->method2()->prop = 'newval';
print "property is :" . $foo->method()->method2()->prop . "\n";
// Don't forget the double-quoted string parser:
print "property is : {$foo->method()->prop}\n";
function afun()
{
return new foo(22);
}
print afun()->prop;
print_r(afun()->method());
示例9: baz
<?php
class foo
{
static $bar = 123;
static function baz()
{
return 456;
}
}
echo foo::$bar;
// will print 123
echo foo::baz();
// will print 456
示例10: testPublic
{
echo "Bar::testPrivate\n";
}
}
class Foo extends Bar
{
public function testPublic()
{
echo "Foo::testPublic\n";
}
private function testPrivate()
{
echo "Foo::testPrivate\n";
}
}
$myFoo = new foo();
$myFoo->test();
// Bar::testPrivate
// Foo::testPublic
/**
Объекты одного типа имеют доступ к элементам с модификаторами private и protected друг друга,
даже если не являются одним и тем же экземпляром. Это объясняется тем, что реализация видимости
элементов известна внутри этих объектов.
Пример #3 Доступ к элементам с модификатором private из объектов одного типа
*/
class Test
{
private $foo;
public function __construct($foo)
{
示例11: teste
public function teste()
{
return foo::x(function &($a = 1, $b) {
});
}
示例12: array
0000727
instantiate a class based on a classname from an array
<?php
class foo
{
var $directive = array('columnClass' => 'bar');
function makeOne()
{
//create a new tableDefinition object
$columnDef =& new $this->directive['columnClass']();
$columnDef->zot();
}
}
class bar
{
function zot()
{
echo "they've spotted us\n";
}
}
$afoo = new foo();
$afoo->makeOne();
?>
示例13: array
[expect php]
[file]
<?php
$f = 'c="foo"';
class foo
{
const foobar = 1;
public $pp = array('t' => null);
function bar()
{
echo $this->t = 'f';
}
function __get($prop)
{
return $this->pp[$prop];
}
function __set($prop, $val)
{
echo "__set";
$this->pp[$prop] = '';
}
}
$f = new foo();
$f->bar();
?>
--EXPECT--
__setf
示例14: __call
<?php
class foo
{
public function __call($a, $b)
{
print "non-static - ok\n";
}
public static function __callstatic($a, $b)
{
print "static - ok\n";
}
}
$a = new foo();
$a->foooo();
$a::foooo();
$b = 'aaaaa1';
$a->{$b}();
$a::$b();
$b = ' ';
$a->{$b}();
$a::$b();
$b = str_repeat('a', 10000);
$a->{$b}();
$a::$b();
$b = NULL;
$a->{$b}();
示例15: bar
<?php
class foo
{
function bar()
{
var_dump(get_class());
}
}
class foo2 extends foo
{
}
foo::bar();
foo2::bar();
$f1 = new foo();
$f2 = new foo2();
$f1->bar();
$f2->bar();
var_dump(get_class());
var_dump(get_class("qwerty"));
var_dump(get_class($f1));
var_dump(get_class($f2));
echo "Done\n";