本文整理汇总了PHP中foo类的典型用法代码示例。如果您正苦于以下问题:PHP foo类的具体用法?PHP foo怎么用?PHP foo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了foo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: barfunc
public function barfunc()
{
// funcdef 1
$x = new foo();
// call 0
$x->foofunc();
// call 1
}
开发者ID:scoates,项目名称:tokalizer,代码行数:8,代码来源:func_multi.php
示例2: bar
function bar()
{
print "calling foo statically:\n";
foo::func();
print "calling foo dynamically:\n";
$foo = new foo();
$foo->func();
print "done\n";
}
开发者ID:jenalgit,项目名称:roadsend-php,代码行数:9,代码来源:bug-id-0001916.php
示例3: foo
function foo($bla)
{
$array = array('key' => 'value', 'anotherKey' => 'anotherValue');
echo 'foo';
foo::foo($param1, $param2);
$this->foo($param3, $param4);
somefunc($param5, $param6);
}
开发者ID:robo47,项目名称:php-manipulator,代码行数:8,代码来源:output4.php
示例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');
}
开发者ID:badlamer,项目名称:hhvm,代码行数:8,代码来源:bug45180.php
示例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";
开发者ID:dw4dev,项目名称:Phalanger,代码行数:31,代码来源:inheritance.php
示例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;
开发者ID:linjunjie,项目名称:php-examples,代码行数:31,代码来源:&.php
示例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();
开发者ID:badlamer,项目名称:hhvm,代码行数:17,代码来源:bug23922.php
示例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());
开发者ID:jenalgit,项目名称:roadsend-php,代码行数:31,代码来源:retval-methodcall.php
示例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
开发者ID:SandyS1,项目名称:presentations,代码行数:14,代码来源:obj_static.php
示例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)
{
开发者ID:AntonBeletsky,项目名称:LearnPHPdocs,代码行数:31,代码来源:Visibility.php
示例11: teste
public function teste()
{
return foo::x(function &($a = 1, $b) {
});
}
开发者ID:badlamer,项目名称:hhvm,代码行数:5,代码来源:call_user_func_005.php
示例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();
?>
开发者ID:jenalgit,项目名称:roadsend-php,代码行数:26,代码来源:bug-id-0000727.php
示例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
开发者ID:dw4dev,项目名称:Phalanger,代码行数:27,代码来源:__set_data_corrupt.php
示例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}();
开发者ID:badlamer,项目名称:hhvm,代码行数:27,代码来源:objects_025.php
示例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";
开发者ID:badlamer,项目名称:hhvm,代码行数:23,代码来源:009.php
示例16: t
function t()
{
$x = 1;
foo::ioo($x, $y);
}
开发者ID:badlamer,项目名称:hhvm,代码行数:5,代码来源:782.php
示例17: zot
$bing = new zot();
//$bing = new zot("asdf");
$bing->afun(34);
zot();
$bing = new argconstructor(12);
$bing->afun(12);
$c = 'argconstructor';
$bap = new $c();
$bpa = new $c(12);
class bar
{
var $baz;
function bar($a = 'noarg')
{
$this->baz = $a;
}
}
class foo
{
var $a = 'bar';
function assign()
{
$zap = new $this->a('setbaz');
print_r($zap);
$zap2 = new $this->a();
print_r($zap);
}
}
$a = new foo();
$a->assign();
print_r($a);
开发者ID:jenalgit,项目名称:roadsend-php,代码行数:31,代码来源:object.php
示例18: foreach
unable to foreach on a class variable
parse error on this code in a class method:
foreach ($this->attributes as $attrKey => $attrVal) {
<?php
class foo
{
var $attributes = array(1 => "Foo", 2 => "Bar");
function zot()
{
foreach ($this->attributes as $attrKey => $attrVal) {
print "{$attrKey}, {$attrVal}\n";
}
}
}
$afoo = new foo();
$afoo->zot();
开发者ID:jenalgit,项目名称:roadsend-php,代码行数:18,代码来源:bug-id-0000700.php
示例19: test_bar
class bar extends foo
{
function test_bar()
{
var_dump(get_parent_class());
}
}
class goo extends bar
{
function test_goo()
{
var_dump(get_parent_class());
}
}
$bar = new bar();
$foo = new foo();
$goo = new goo();
$foo->test();
$bar->test();
$bar->test_bar();
$goo->test();
$goo->test_bar();
$goo->test_goo();
var_dump(get_parent_class($bar));
var_dump(get_parent_class($foo));
var_dump(get_parent_class($goo));
var_dump(get_parent_class("bar"));
var_dump(get_parent_class("foo"));
var_dump(get_parent_class("goo"));
var_dump(get_parent_class("i"));
var_dump(get_parent_class(""));
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:1458.php
示例20: bar
<?php
class foo
{
public function bar() : callable
{
$test = "one";
return function () use($test) : array {
return null;
};
}
}
$baz = new foo();
var_dump($func = $baz->bar(), $func());
开发者ID:gleamingthecube,项目名称:php,代码行数:14,代码来源:Zend_tests_return_types_013.php
注:本文中的foo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论