PHP 7 callback references

raw

callback-references.php

1
2
3
4
5
6
7
8
9
10
11
<?php
function l($m) {
    echo $m . "\n";
}
 
$cb = 'l';
call_user_func($cb, 'hi');
 
$cb2 = &$cb;
call_user_func($cb2, 'hi2');
?>
raw

output-php7.txt

hi
Warning: call_user_func() expects parameter 1 to be a valid callback, no array or string given in /in/D9PjW on line 10

see http://3v4l.org/D9PjW#vphp7@20150101
Christian Weiske Christian Weiske
owner

History