Closure::call
(PHP 7, PHP 8)
Closure::call — 繫結並呼叫閉包
參數
- 
newThis
- 
     在呼叫期間將閉包繫結到 object。 
- 
args
- 
     零個或多個參數,他們將作為參數傳遞給閉包。 
返回值
返回閉包的返回值。
範例
示例 #1 Closure::call() 示例
<?php
class Value {
    protected $value;
    public function __construct($value) {
        $this->value = $value;
    }
    public function getValue() {
        return $this->value;
    }
}
$three = new Value(3);
$four = new Value(4);
$closure = function ($delta) { var_dump($this->getValue() + $delta); };
$closure->call($three, 4);
$closure->call($four, 4);
?>
以上例程會輸出:
int(7) int(8)