503f75d08b
These names don't make sense now that we run both suites the same way.
27 linhas
506 B
PHP
27 linhas
506 B
PHP
<?php
|
|
|
|
class Callbacks {
|
|
public $count = 0;
|
|
public function filter($n) {
|
|
$this->count++;
|
|
return $n % 2;
|
|
}
|
|
|
|
public static $scount = 0;
|
|
public static function sfilter($n) {
|
|
self::$scount++;
|
|
return $n % 3;
|
|
}
|
|
}
|
|
|
|
function main() {
|
|
$a = array(1,2,3,4,5,6,7,8);
|
|
$cb = new Callbacks();
|
|
var_dump(array_filter($a, array($cb, 'filter')));
|
|
echo $cb->count . " times\n";
|
|
|
|
var_dump(array_filter($a, array('Callbacks', 'sfilter')));
|
|
echo Callbacks::$scount . " times\n";
|
|
}
|
|
main();
|