当前位置: 首页>>代码示例>>PHP>>正文


PHP foo::bar方法代码示例

本文整理汇总了PHP中foo::bar方法的典型用法代码示例。如果您正苦于以下问题:PHP foo::bar方法的具体用法?PHP foo::bar怎么用?PHP foo::bar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在foo的用法示例。


在下文中一共展示了foo::bar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: bar

<?php

error_reporting(E_ALL);
class foo
{
    public function bar()
    {
        $x = array();
        $x[] = 3;
        $x[] = array(1, 5);
        $x[] = new foo();
        return $x;
    }
}
$foo = new foo();
var_dump($x = $foo->bar()[1]);
var_dump($foo->bar()[1][1]);
var_dump($x[0]);
var_dump($x = $foo->bar()[2]);
var_dump($x->bar());
var_dump($x->bar()[0]);
$x = array();
$x[] = new foo();
var_dump($x[0]->bar()[2]);
var_dump($foo->bar()[2]->bar()[1]);
var_dump($foo->bar()[2]->bar()[2]->bar()[1][0]);
var_dump($foo->bar()[2]->bar()[2]->bar()[1][0][1]);
var_dump($foo->bar()[2]->bar()[2]->bar()[4]);
var_dump($foo->bar()[3]->bar());
开发者ID:lsqtongxin,项目名称:hhvm,代码行数:29,代码来源:dereference_002.php

示例2: bar

<?php

namespace foobar;

class foo
{
    public function bar(self $a)
    {
    }
}
$foo = new foo();
$foo->bar($foo);
// Ok!
$foo->bar(new \stdclass());
// Error, ok!
开发者ID:badlamer,项目名称:hhvm,代码行数:15,代码来源:bug43332_1.php

示例3: 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

示例4: bar

[expect php]
[file]
<?php 
class foo
{
    function bar()
    {
        $args = func_get_args();
        foreach ($args as $arg) {
            echo $arg;
        }
    }
}
$x = new foo();
$x->bar('ahoj', 13);
开发者ID:dw4dev,项目名称:Phalanger,代码行数:15,代码来源:func_get_args.php

示例5: bar

<?php

class foo
{
    function bar()
    {
        print "Hey there!\n";
    }
}
foo::bar();
开发者ID:NageshVeeravalli,项目名称:web-qa,代码行数:10,代码来源:testclassfunc.php

示例6: 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

示例7: __construct

<?php

final class foo
{
    public $bar;
    private $foo = 0;
    public function __construct($bar)
    {
        $this->bar = $bar;
    }
    public function foo()
    {
        return ++$this->foo;
    }
    public static function bar()
    {
        return new self(123);
    }
}
$foo = new foo('azerty');
echo $foo->foo() . "\n";
echo $foo->bar . "\n";
echo foo::bar()->bar . "\n";
开发者ID:rom1504,项目名称:php-parser,代码行数:23,代码来源:test.php

示例8: bar

<?php

class foo
{
    public function bar() : callable
    {
        $test = "one";
        return function () use($test) : array {
            return array($test);
        };
    }
}
$baz = new foo();
var_dump($baz->bar());
开发者ID:gleamingthecube,项目名称:php,代码行数:14,代码来源:Zend_tests_return_types_012.php

示例9: bar

    {
        $this->val = 1;
    }
    function bar()
    {
        echo $this->val;
        $ref =& $this;
        $ref->val = 2;
        echo $this->val;
        $ref2 = $this;
        $ref2->val = 3;
        echo $this->val;
        $x = new foo();
        echo $x->val;
        $ref3 =& $x;
        $ref3->val = 4;
        echo $x->val;
        $ref4 = $x;
        $ref4->val = 5;
        echo $x->val;
    }
    var $val;
}
$x = new foo();
$x->bar();
$ref5 = $x;
$ref5->val = 6;
echo $x->val;
$ref6 =& $x;
$ref6->val = 7;
echo $x->val;
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:774.php

示例10: testfunc

[expect php]
[file]
<?php 
function testfunc($var)
{
    echo "testfunc {$var}\n";
}
class foo
{
    public $arr = array('testfunc');
    function bar()
    {
        $this->arr[0]('testvalue');
    }
}
$a = new foo();
$a->bar();
开发者ID:dw4dev,项目名称:Phalanger,代码行数:17,代码来源:bug25652.php

示例11: main

function main()
{
    $l = new foo();
    $l->bar();
}
开发者ID:badlamer,项目名称:hhvm,代码行数:5,代码来源:multiple_closures.php

示例12: __construct

    function __construct()
    {
        echo "class ok\n";
    }
    static function bar()
    {
        return "method ok\n";
    }
}
function f1($x = namespace\C)
{
    return $x;
}
function f2($x = namespace\foo::C)
{
    return $x;
}
function f3(namespace\foo $x)
{
    return "ok\n";
}
echo namespace\C;
echo namespace\foo();
echo namespace\foo::C;
echo namespace\foo::C2;
echo namespace\foo::$var;
echo namespace\foo::bar();
echo namespace\f1();
echo namespace\f2();
echo namespace\f3(new namespace\foo());
echo namespace\unknown;
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:ns_058.php

示例13: bar

<?php

class foo
{
    public $test = 0;
    private $test_2 = 1;
    protected $test_3 = 2;
    public function bar()
    {
        try {
            throw new Exception('foo');
        } catch (Exception $this) {
            var_dump($this);
        }
        $this->baz();
    }
    public function baz()
    {
        foreach ($this as $k => $v) {
            printf("'%s' => '%s'\n", $k, $v);
        }
        print "ok\n";
    }
}
$test = new foo();
$test->bar();
开发者ID:badlamer,项目名称:hhvm,代码行数:26,代码来源:030.php

示例14: def_md

<?php

def_md('foo\\bar', 5, function () {
    echo '.';
    return "1\n";
});
def_md('foo::bar', 5, function () {
    echo '.';
    return "2\n";
});
echo foo\bar();
echo foo\bar();
echo foo::bar();
echo foo::bar();
?>
---
.1
1
.2
2
开发者ID:najomi,项目名称:najomi.org,代码行数:20,代码来源:_symbols-in-function-name.php

示例15: __construct

--TEST--
Bug #27504 (call_user_func_array allows calling of private/protected methods)
--FILE--
<?php 
class foo
{
    function __construct()
    {
        $this->bar('1');
    }
    private function bar($param)
    {
        echo 'Called function foo:bar(' . $param . ')' . "\n";
    }
}
$foo = new foo();
call_user_func_array(array($foo, 'bar'), array('2'));
$foo->bar('3');
?>
--EXPECTF--
Called function foo:bar(1)
Warning: expects parameter 1 to be valid callback, cannot access in %s on line %d at pos %d

Fatal error: Call to private method foo::bar() from context '' in %s on line %d, position %d
开发者ID:lihuibin,项目名称:jphp,代码行数:24,代码来源:bug27504.php


注:本文中的foo::bar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。