- var_dump: documentation ( source)
- printf: documentation ( source)
<?php
class A
{
public function getFunc($text)
{
return function() use ($text) {
$withNewLine = $text.PHP_EOL;
printf("From the inside: %s", $withNewLine);
return $withNewLine;
};
}
}
$b = new A();
$func = $b->getFunc('can i has var');
$func();
$c = $b->getFunc('can i has var')();
echo 'From the outside:'.PHP_EOL;
echo $c;
var_dump($func = $b->getfunc("can i has var")());