PHP » GoLang |
login |
register |
about
|
GoLang Closure::bindTo
request it (388)
GoLang replacement for PHP's Closure::bindTo
[edit | history]
Closure::bindTo(PHP 5 >= 5.4.0, PHP 7) Closure::bindTo — Duplicates the closure with a new bound object and class scope DescriptionCreate and return a new anonymous function with the same body and bound variables as this one, but possibly with a different bound object and a new class scope.
The “bound object†determines the value $this will
have in the function body and the “class scope†represents a class
which determines which private and protected members the anonymous
function will be able to access. Namely, the members that will be
visible are the same as if the anonymous function were a method of
the class given as value of the
Static closures cannot have any bound object (the value of the parameter
This function will ensure that for a non-static closure, having a bound
instance will imply being scoped and vice-versa. To this end,
non-static closures that are given a scope but a
Parameters
Return Values
Returns the newly created Closure object
or Changelog
ExamplesExample #1 Closure::bindTo() example
<?php The above example will output something similar to: 1 2 See Also
|
more
Recently updated
more
Most requested
more
Last requests
|